Insertion in Binary Search Tree | Insertion in BST | Iteratively & Recursively | DSA-One Course #67

Поділитися
Вставка
  • Опубліковано 3 лют 2025

КОМЕНТАРІ •

  • @nittinrana2277
    @nittinrana2277 3 роки тому +7

    Nice content thanks Bhaiya for uploading video more frequently

  • @AdilKhan-we3wb
    @AdilKhan-we3wb 3 роки тому +3

    Thanks bhaiya... I was actually thinking and trying the code with iterative approach for the last 2 days.I have somewhat reached but still i was not able to complete the code. But now it is crystal clear.. The gem for iterative approach is the current and parent pointer ( i was coding in C ) .. Thanks a lot .

  • @arpanmaheshwari2290
    @arpanmaheshwari2290 3 роки тому +4

    Love you bhaiya first

  • @tech_wizard9315
    @tech_wizard9315 3 роки тому +17

    Please make a 60 roadmap on important DSA topics for DSA beginner to crack tech giant's like Microsoft Amazon level companies

  • @er.skelafahmed
    @er.skelafahmed 3 роки тому +1

    Thanks bhaiya...for your uploading speed. ❤️

  • @pallavigavali2671
    @pallavigavali2671 3 роки тому +4

    Thank you bhaiya ❤️

  • @vivekshokeen1192
    @vivekshokeen1192 3 роки тому +4

    Bhaiya can you upload video on springboot briefly describing from interview perspective.Thanks for the amazing videos.love❤

  • @lavinamaheshwari
    @lavinamaheshwari Рік тому

    Amazing explanation!

  • @ashutosh7597
    @ashutosh7597 Рік тому

    Best explaination

  • @sudhanshudubey7267
    @sudhanshudubey7267 3 роки тому +3

    bhaiya please make detailed video on hackathons

  • @laughgenerator7907
    @laughgenerator7907 2 роки тому +2

    Node insert(Node root, int Key) {
    Node newnode = new Node(Key);
    Node curr=root;
    Node parent=null;
    while(curr!=null){
    parent=curr;
    if(Key

  • @abhaysingh7862
    @abhaysingh7862 3 роки тому +2

    Thank u bhaiya

  • @abhishekdutta7064
    @abhishekdutta7064 2 роки тому

    Nice explanation sir😌

  • @saritaprasad4295
    @saritaprasad4295 2 роки тому

    Nice explanation

  • @sumantagorai5880
    @sumantagorai5880 5 місяців тому +1

    When insert an element already present inside the tree in this case the iteration logic provided in this video was not pass all test case of GFG, was it happened with others?

  • @aishwaryshukla8880
    @aishwaryshukla8880 2 роки тому +9

    Use this iterative code to pass all testcases of GFG:
    Node insert(Node root, int Key) {
    // your code here
    //Recursive method is commented out, iterative method is uncommented currently
    // if (root == null){
    // return new Node(Key);
    // }
    // if (root.data > Key){
    // root.left = insert(root.left, Key);
    // }else if (root.data < Key){
    // root.right = insert(root.right, Key);
    // }
    // return root;

    Node newNode = new Node(Key);
    Node cur = root;
    Node parent = null;
    while (cur != null){
    parent = cur;
    if (cur.data == Key) return root; //this line handles if K is already present in BST
    if (cur.data > Key)
    cur = cur.left;
    else
    cur = cur.right;
    }
    if (parent == null) {
    return newNode;
    }
    else if (parent.data < Key){
    parent.right = newNode;
    }else parent.left = newNode;
    return root;
    }

  • @v.k1454
    @v.k1454 3 роки тому +2

    Sir prepare will tell me whether recorder app is hybrid or not nebread

  • @harry-cf4ii
    @harry-cf4ii 3 роки тому +6

    Bhaiya when can we expect this course to finish??and whats ur next plan after this DSA-one course?

  • @sonasonali8583
    @sonasonali8583 3 роки тому +1

    please add some more videos on android development tutorials.

  • @vikasprajapati6558
    @vikasprajapati6558 3 роки тому +3

    bhaiya what is your other source of income now ? k

  • @apoorvvikramsinghrathore7189
    @apoorvvikramsinghrathore7189 2 роки тому

    nice sir

  • @divyanshiyadav9120
    @divyanshiyadav9120 3 роки тому

    Bhaiya how long th is course will continue ❤️❤️

  • @kapiljetwani3540
    @kapiljetwani3540 3 роки тому +1

    bhaiya can u plzz make a video on rabin karp and kmp pattern matching algo's with code i am finding it really difficult to understand😊😊

  • @ansh7256
    @ansh7256 Рік тому

    Replace x and key with Key

  • @saswatapatra5919
    @saswatapatra5919 2 роки тому +1

    bhaiyya second code mei what is cur.key? if cur is a node type value then it shouldnt have an attribute named key right?

  • @priyanshemarldluke5048
    @priyanshemarldluke5048 3 роки тому

    Bhaiya flutter wali playlist start krona jaldi please

  • @yesgk-o9o
    @yesgk-o9o 3 роки тому

    Bhaiya kabtak complete karbaoge DSA course ❤️
    Please reply

  • @itspodify2021
    @itspodify2021 3 роки тому

    Bhaiya pls GROUPON sde intern ke preparation se related kisi se experience share krwa dijiye 🙏🙏🙏🙏🙏🙏
    UA-cam pe Groupon ki prep ka koi content available nhi hai

  • @chandrakantmandal___
    @chandrakantmandal___ 3 роки тому +1

    Python video bhaiya

  • @nirvanjain3021
    @nirvanjain3021 3 роки тому

    can you please share code?

    • @bhushankorg5606
      @bhushankorg5606 2 роки тому

      Node* insert(Node* root, int Key) {
      // Your code here
      if(root == NULL){
      root = new Node(Key);
      return root;
      }
      Node *curr = root, *parent = root;
      while(curr != NULL){
      parent = curr;
      if(Key == curr->data){
      return root;
      }
      else if(Key < curr->data){
      curr = curr->left;
      }
      else{
      curr = curr->right;
      }
      }
      curr = new Node(Key);
      if(Key < parent->data){
      parent->left = curr;
      }
      else{
      parent->right = curr;
      }
      return root;
      }

  • @Daddyboltee
    @Daddyboltee 2 роки тому

    where did i do wrong its been 25 min but i coudn't find it welcome if anybody give favor in it..
    class Solution {
    // Function to insert a node in a BST.
    Node insert(Node root, int Key) {
    Node newnode = new Node(key);
    Node current = root;
    Node Parent = null;
    while(key != current.key){
    Parent = current;
    if(key < current.key){
    current = current.left;
    }else{
    current = current.right;
    }if(Parent == null){
    Parent = newnode;
    }elsif(key < Parent.key){
    Parent.left = newnode;
    }else{
    Parent.right = newnode;
    }
    return root;
    }
    }

  • @suimishaikh2908
    @suimishaikh2908 3 роки тому

    Bhaiya I am new or muje pata nhi hai ki DSA eitna hi hai

  • @M10-r8q7h
    @M10-r8q7h 8 місяців тому

    subs at the start are crazy🥲🥲