Build Tree from Preorder and Inorder | C++ Placement Course | Lecture 27.3

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024
  • Complete C++ Placement Course (Data Structures+Algorithm) : • C++ Full Course | C++...
    Telegram: t.me/apnikaksh...
    Instagram: / dhattarwalaman
    Notes of this Lecture:

ความคิดเห็น • 161

  • @gauravsharma3444
    @gauravsharma3444 ปีที่แล้ว +10

    You really made it much easier than other channels

  • @MohammadKhan-ld1xt
    @MohammadKhan-ld1xt 3 ปีที่แล้ว +40

    Everyone, just try to appreciate the effort that they are putting for us .
    Be patient , they have to upload c++ , java , web development,.. so it takes time
    Just be patient and appreciate them
    Thank you Aman bhaiyya and the whole team 👍

    • @sumitmukharjee5816
      @sumitmukharjee5816 3 ปีที่แล้ว +8

      I was waiting for this golden comment after all they are providing this for free it takes time to create quality content

    • @sleepypanda7172
      @sleepypanda7172 3 ปีที่แล้ว +4

      thank god these type of ppl exists. It feels so bad how others are humiliating the team in comment section without a pinch of appreciation

  • @aayushvyas6270
    @aayushvyas6270 3 ปีที่แล้ว +11

    commented code for reference
    struct node{
    int data;
    node* left = NULL;
    node* right = NULL;
    node(int data):data(data){}
    };
    int searchInOrder(int InOrder[],int start,int end,int curr){
    for(int j=start;j

  • @adityabhandari6688
    @adityabhandari6688 3 ปีที่แล้ว +6

    10 times better explanation than what that previous bhaiya would have explained

    • @adityabhandari6688
      @adityabhandari6688 3 ปีที่แล้ว +1

      yes here is the code:
      #include
      using namespace std;
      struct Node
      {
      int data;
      struct Node *left;
      struct Node *right;
      Node(int value)
      {
      data = value;
      left = NULL;
      right = NULL;
      }
      };
      int searchPosition(int inorder[], int start, int end, int curr)
      {
      for (int i = start; i end)
      {
      return NULL;
      }
      int curr = preorder[idx];
      idx++;
      Node *newroot = new Node(curr);
      // if (start == end)
      // {
      // return newroot;
      // }
      int pos = searchPosition(inorder, start, end, curr);
      newroot->left = buildTree(preorder, inorder, start, pos - 1);
      newroot->right = buildTree(preorder, inorder, pos + 1, end);
      return newroot;
      }
      void Inorderprint(Node *root)
      {
      if (root == NULL)
      {
      return;
      }
      Inorderprint(root->left);
      cout data right);
      }
      int main()
      {
      int preorder[] = {1, 2, 4, 3, 5};
      int inorder[] = {4, 2, 1, 5, 3};
      Node *root = buildTree(preorder, inorder, 0, 4);
      Inorderprint(root);
      return 0;
      }

  • @shubhamgite7730
    @shubhamgite7730 2 ปีที่แล้ว +4

    Super video🤗🤗.. Concept/logic ekdam तगडे level pe clear ho gaya..♥️🔥🔥

  • @asifiqbalsekh
    @asifiqbalsekh 2 ปีที่แล้ว +2

    Maja Agaya Mam....Mujhe aj pta chala apko Microsoft kue mila tha....badiya explain kiye hai ap...thanks

  • @mohakgidwani1505
    @mohakgidwani1505 3 ปีที่แล้ว +47

    Please upload Notes as well !!

    • @scriptkiddie6151
      @scriptkiddie6151 3 ปีที่แล้ว +2

      What are you going to do with notes lol?

    • @rahul_ji21
      @rahul_ji21 3 ปีที่แล้ว +4

      @@scriptkiddie6151 😂😂😂 ye log bi na

  • @anumoynandy5811
    @anumoynandy5811 3 ปีที่แล้ว +27

    But it should be possible when all the node values are unique otherwise the search function gives us random index

    • @avronilbanerjee5302
      @avronilbanerjee5302 2 ปีที่แล้ว +3

      Suppose you have two 3's, Koi v index dede uska value to 3 hi set hoga tree mai right, By the way binary search tree me duplicate values allowed v nahi hai

    • @aishikbasu5230
      @aishikbasu5230 2 ปีที่แล้ว

      @Overthinker_stuff node->left or node->right will be assigned as null when the base condition will be executed

  • @girishporwal5183
    @girishporwal5183 3 ปีที่แล้ว +9

    Explainations have become awesome
    ty AC team

  • @adamyasharma_0135
    @adamyasharma_0135 8 หลายเดือนก่อน

    best approach on the internet for this question

  • @user-uj9ds1nr5z
    @user-uj9ds1nr5z 5 หลายเดือนก่อน +1

    Thanks so much 😊😊😊😊😊😊😊

  • @K_EC_AnuragKumarMishra
    @K_EC_AnuragKumarMishra 2 ปีที่แล้ว +2

    you guys have been doing great work...thanks a lot....great explanation

  • @mafiafiazmafiafiaz3410
    @mafiafiazmafiafiaz3410 ปีที่แล้ว

    Dedi Shareda Inshallah sbho parrahy gy😊😊 Nice teaching method❤❤

  • @Suuuuuuuuuuuuuubrat
    @Suuuuuuuuuuuuuubrat 3 ปีที่แล้ว +4

    It is really awesome. This is a video with perfect explanation and code😍😍😍

  • @sayantaniguha8519
    @sayantaniguha8519 3 ปีที่แล้ว +46

    We really need the notes for this

    • @aayushsingh4075
      @aayushsingh4075 2 ปีที่แล้ว +3

      I think providing notes was a gimmick to attract people toward this playlist because no notes are provided for the later videos which have the main + complex topics...!!!

    • @supernova4467
      @supernova4467 2 ปีที่แล้ว

      Make yourself

  • @zeeshanalic
    @zeeshanalic ปีที่แล้ว +3

    why we need to make a (inorder)tree from inorder and preorder tree, when we already have output same as inorder tree?

  • @chiragjaiswal9387
    @chiragjaiswal9387 3 ปีที่แล้ว +9

    Pls Include Time Complexity and space complexity With Videos Too

  • @sakibcse4238
    @sakibcse4238 2 ปีที่แล้ว +4

    Full Source Code:
    #include
    using namespace std;
    class Node {
    public:
    int data;
    Node* left;
    Node* right;
    Node(int val){
    data = val;
    left = NULL;
    right = NULL;
    }
    };
    int search(int inorder[], int start,int end, int curr){
    for(int i=start; i end) return NULL;
    int curr = preorder[idx];
    idx++;
    Node* node = new Node(curr);
    if(start == end) return node;
    int pos = search(inorder, start, end, curr);
    node->left = buildTree(preorder, inorder, start, pos-1);
    node->right = buildTree(preorder, inorder, pos+1, end);
    }
    void inorderPrint(Node* root){
    // cout

    • @HelloWorld-lh1wk
      @HelloWorld-lh1wk ปีที่แล้ว

      can you suggest me a good place to learn pointers like the one used

  • @gulshanrajput2458
    @gulshanrajput2458 ปีที่แล้ว +1

    If we use HashMap (Java)for searching position it may become O(n)

  • @princekumar-vi2tg
    @princekumar-vi2tg 3 หลายเดือนก่อน

    really nice explanations.. thanks mam

  • @tashidhondup6502
    @tashidhondup6502 3 ปีที่แล้ว +3

    I am waiting......

  • @adityamahilane5709
    @adityamahilane5709 2 ปีที่แล้ว +4

    Thankyou shraddha mam😊
    Mam aap agar shource code provide kr paye it can be more better

  • @saikeerthanchiluka4027
    @saikeerthanchiluka4027 ปีที่แล้ว

    Superb explanation dhidhi

  • @ramankr0022
    @ramankr0022 ปีที่แล้ว

    very helpful. thanks for uploading.

  • @prashantchakrawarti42
    @prashantchakrawarti42 3 ปีที่แล้ว +3

    Thanku soo much sirji & Didi ji 🙏

  • @harshpanwar1550
    @harshpanwar1550 2 ปีที่แล้ว

    That was an amazing explanation...
    Thank u didi🔥🔥

  • @shivanshshukla8911
    @shivanshshukla8911 3 ปีที่แล้ว +12

    condition : if(start==end) return node; is not necessary, right??? [ as base condition ,ie, if(start>end) return NULL; is enough]

    • @Ravipoddar1999
      @Ravipoddar1999 3 ปีที่แล้ว +3

      yes base condition handles all the edges cases

    • @tinywhiskey8429
      @tinywhiskey8429 3 ปีที่แล้ว

      Base cond'n is sufficient.

  • @millennialalchemist1347
    @millennialalchemist1347 3 ปีที่แล้ว +3

    Thank you aman bhaiyya🙏🙌

  • @dvaderaws
    @dvaderaws 2 ปีที่แล้ว +1

    Beautifully explained. Well done.

  • @rajatverma5841
    @rajatverma5841 2 ปีที่แล้ว

    will ever base case come( s>e) ??

  • @ABHAYKUMAR-rh4jc
    @ABHAYKUMAR-rh4jc 2 ปีที่แล้ว

    thanks

  • @atin_jagotra
    @atin_jagotra 3 ปีที่แล้ว +2

    I wasted a whole hour trying to learn this. You guys made it so simple. Thankyou for all of it

  • @CodingMonster23
    @CodingMonster23 6 หลายเดือนก่อน +1

    Notes please

  • @chiragjaiswal9387
    @chiragjaiswal9387 3 ปีที่แล้ว +1

    Optimisation Needed

  • @vrajparikh8630
    @vrajparikh8630 2 ปีที่แล้ว

    very similar to quick sort.

  • @tiger20studio80
    @tiger20studio80 3 ปีที่แล้ว +3

    🙂

  • @mohdhumaid5508
    @mohdhumaid5508 2 ปีที่แล้ว

    zaero...nice

  • @anshulsharma9649
    @anshulsharma9649 ปีที่แล้ว

    why we take idx static type in buildtree method

  • @pranaymishra4407
    @pranaymishra4407 2 ปีที่แล้ว +1

    my inorderPrint( ) function is printing preorder
    what could be the error in my coding ?

  • @shikhamaurya4453
    @shikhamaurya4453 3 ปีที่แล้ว +4

    You guys are really awesome.
    Also thanks for adding that algorithm slide,it helped while revising.

  • @Sarajboos12
    @Sarajboos12 2 ปีที่แล้ว +2

    what is time complexity?

  • @aa-zindgi
    @aa-zindgi 3 ปีที่แล้ว +4

    Aman bhaiyaa ji bahut achha kaam kar rahe ho,
    But sath sath jhoot bhi bolna sikha rahe ho,
    Aapne start m bola tha notes, practice ke liye questions , brain teaser milte rahenge but yahan tak aate aate sab gayab ho gaya 😭

  • @nikhilsinghjadon39
    @nikhilsinghjadon39 3 ปีที่แล้ว +2

    but this is not an optimised solution..the time complexity of this program is O(n^2)..which not an efficient one..

  • @dhruvkumar4326
    @dhruvkumar4326 3 ปีที่แล้ว +1

    plz python walla course complete krdooo

  • @Ankit18411
    @Ankit18411 2 ปีที่แล้ว

    What will search function return if there is one of the data in left of root is equal to root->data?? I think it will not return correct root pos

  • @Kingpin37
    @Kingpin37 2 ปีที่แล้ว

    sleep saver 🤝

  • @aparnamittal8653
    @aparnamittal8653 3 ปีที่แล้ว +2

    What is the complexity here?

    • @isheoran
      @isheoran 3 ปีที่แล้ว

      In average case it should be nlog(n)

    • @pulkitranjan4002
      @pulkitranjan4002 2 ปีที่แล้ว

      O(n2)

  • @UmeshKumar-qw9op
    @UmeshKumar-qw9op 3 ปีที่แล้ว

    Please apload notes all lecture please sir

  • @rambabupatidar3092
    @rambabupatidar3092 2 ปีที่แล้ว +1

    this code is not running when the preOrder arr is 1 2 3 4 5 6 7 and its the inOrder arr is 4 2 5 1 6 3 7
    formally it is not running for more than 5 values

    • @anushthakumari2393
      @anushthakumari2393 2 ปีที่แล้ว

      You might have not changed the value in the main function in build tree part
      In passing the value in build tree

  • @raghavpareek876
    @raghavpareek876 9 หลายเดือนก่อน

    where could I find the notes for dsa c++

  • @SajjadAhmed-lc2dr
    @SajjadAhmed-lc2dr 2 ปีที่แล้ว

    oye agr buildtree k last main return node na likho tab v root pointer acquire value of root node y???????

  • @shubhamXmandal
    @shubhamXmandal 3 ปีที่แล้ว +1

    So, she take preorder as a input and print the same preorder --\(*_*)/--

  • @chandrakantkumarchoudhary1144
    @chandrakantkumarchoudhary1144 3 ปีที่แล้ว +1

    yaar ye stub kya hai?

  • @007yashkumar2
    @007yashkumar2 3 ปีที่แล้ว

    wah didi apne tho moj kar di

  • @anshulbhardwaj2666
    @anshulbhardwaj2666 2 ปีที่แล้ว

    Please upload notes of the lecture

  • @SajjadAhmed-lc2dr
    @SajjadAhmed-lc2dr 2 ปีที่แล้ว

    how buildtree function is returning address of root node to pointer root in main can somebody explain

  • @AnujYadav-os6kj
    @AnujYadav-os6kj ปีที่แล้ว

    getting error in printing inorder traversal

  • @rohitchauhan6170
    @rohitchauhan6170 3 ปีที่แล้ว +1

    i am having an issue the class node above the code is not shown properly in this video can you please sent the class node as i have skipped some classes..

    • @jiosim1377
      @jiosim1377 3 ปีที่แล้ว

      First watch those videos

  • @shikharjoshi2998
    @shikharjoshi2998 ปีที่แล้ว

    can someone plz explain me the base condition of buildtree as i am not able to get that

  • @adarshpandey4899
    @adarshpandey4899 3 ปีที่แล้ว

    Plzz upload web Dev course also

  • @its_neel_ok
    @its_neel_ok 3 ปีที่แล้ว

    9:38 what is the difference between Node and node there??????

    • @siddharth4069
      @siddharth4069 3 ปีที่แล้ว

      LHS signifies the new node that is being created and RHS signifies the value that is being stored in the new node

  • @ece193abhishekgupta2
    @ece193abhishekgupta2 2 ปีที่แล้ว

    Plz help ,i am not getting any output.Whats the mistake here?
    #include
    using namespace std;
    class node{
    public:
    int data;
    node* left;
    node* right;
    node(int val){
    data=val;
    left=NULL;
    right=NULL;
    }
    };
    int search(int inorder[],int start,int end,int curr){
    for(int i=start;iend){
    return NULL;
    }

    int curr=preorder[idx];
    idx++;
    node* root=new node(curr);

    if(start==end){
    return root;}
    int pos=search(inorder,start,end,curr);
    root->left=formtree(preorder,inorder,start,pos-1);
    root->right=formtree(preorder,inorder,pos+1,end);
    return root;
    }
    void inorderprint(node* k){
    if(k==NULL){
    return;
    }
    inorderprint(k->left);
    cout

    • @UdyatJainBCE
      @UdyatJainBCE 2 ปีที่แล้ว

      bro same issue can u help pls?

  • @rpo-weedealercodm4163
    @rpo-weedealercodm4163 หลายเดือนก่อน

    They are deleting negative comments (majority) . that is why you can see the views and comments ratio. What a joke guys. the explanation is very bad.

  • @omkarsase6518
    @omkarsase6518 3 ปีที่แล้ว +2

    9:10 what is the logic behind -writing the static in front of int index

    • @palashagrawal2343
      @palashagrawal2343 3 ปีที่แล้ว +3

      static isliye kar rahe hai taaki recurssion use karte samay idx ka value purana wala store rahe.agar static use nahi karenge toh idx =0 ya 1 hi hoga aur error throw karega

    • @willturner3440
      @willturner3440 3 ปีที่แล้ว +6

      Tum global bhi declare skte static ki jagah

    • @ROHITKUMAR-pn4gj
      @ROHITKUMAR-pn4gj 3 ปีที่แล้ว

      @@palashagrawal2343 but in the gfg i submitted its giving runtime error for the static int 🤔

    • @gauravupreti9340
      @gauravupreti9340 3 ปีที่แล้ว +1

      @@ROHITKUMAR-pn4gj Declaring static variables inside a class has a different method, you have to declare them outside the class, like this.
      class sample
      {
      public:
      static int i;
      };
      int sample::i = 0;

    • @baidyanathroy7726
      @baidyanathroy7726 2 ปีที่แล้ว

      @@palashagrawal2343 ty bro.

  • @indiraparajuli9715
    @indiraparajuli9715 2 ปีที่แล้ว

    Why it is not working i typed the same code as shown in the video?
    #include
    using namespace std;
    struct Node{
    int data;
    struct node* left;
    struct node* right;
    Node(int val){
    data = val;
    left = NULL;
    right = NULL;
    }
    };
    int search(int inorder[], int start, int end, int curr){
    for(int i=start; i end){
    return NULL;
    }
    int curr = preorder[idx];
    idx++;
    Node* node = new Node(curr);
    if(start == end){
    return node;
    }
    int pos = search(inorder, start, end, curr); node->left = buildTree(preorder, inorder, start, pos-1);
    node->right = buildTree(preorder, inorder, pos+1, end);
    return node;
    }
    void inorderprint(Node* root){
    if(root == NULL)
    return;
    inorderprint(root -> left);
    cout

    • @sarthaksinghrajput5462
      @sarthaksinghrajput5462 2 ปีที่แล้ว

      #include
      using namespace std;
      class Node{
      public:
      int data;
      Node* left;
      Node* right;
      Node(int val){
      data = val;
      left = NULL;
      right = NULL;
      }
      };
      int search(int inorder[], int start, int end, int curr){
      for(int i = start; i end){
      return NULL;
      }
      int curr = preorder[idx];
      idx++;
      Node* node = new Node(curr);
      /*if(start == end){
      return node;
      }*/
      int pos = search(inorder, start, end, curr);
      node->left = buildtree(preorder, inorder, start, pos-1);
      node->right = buildtree(preorder, inorder, pos+1, end);
      return node;
      }
      void inorderprint(Node* root){
      if(root == NULL){
      return;
      }
      inorderprint(root->left);
      cout

    • @rishabhrawatt
      @rishabhrawatt 2 ปีที่แล้ว

      because at starting you passed struct node*left and right (you have to pass in capital means struct Node*) because you initialize node with capitals .

  • @fantastic1046
    @fantastic1046 2 ปีที่แล้ว

    Can we make binary trees for alphabets (char) instead of numbers😅😅

  • @satwikpal9161
    @satwikpal9161 2 ปีที่แล้ว

    pls add the notes

  • @sumanjoshi3778
    @sumanjoshi3778 3 ปีที่แล้ว +2

    Sir agar aap ko notes nahi provide karne theek hai per program to provide kar do. Vasie kitna bolate ho free content kaha hai free content video ke saath notes bhi free content ke andr hi ate hai.

    • @PankajSingh-vi3fy
      @PankajSingh-vi3fy 3 ปีที่แล้ว +4

      Bhai time lagta hai banda ek channel nhi chala rha hai... or itne mehnat kr rha hai free mai lectures de rha hai.... jaake purane notes check kroo unme update hua hai unko or detailed kr diya hai.... improvement mai time lagta hai orr notes koi bdee baat nhi hai... khud bhi lecture dekh k bna skte ho.... rough mai likh lo video dekhte waqt fir fair up kroo nhi toh gfg pr dekh loo

  • @aakashmodi441
    @aakashmodi441 2 ปีที่แล้ว

    didi iska code toh de doo aap notes bahut hii jaruri hai iska

  • @palakbiswas1814
    @palakbiswas1814 3 ปีที่แล้ว +2

    this course made me fall in love with coding

  • @kunalaggarwal1928
    @kunalaggarwal1928 3 ปีที่แล้ว

    what if there are duplicate values in array , this will not work , any solutions ?

    • @yashchauhan5852
      @yashchauhan5852 3 ปีที่แล้ว +1

      impossible for duplicate elements

    • @mancunianswagger3668
      @mancunianswagger3668 3 ปีที่แล้ว

      Lol have u ever seen duplicates in a tree😂😂

  • @anuragpandey3341
    @anuragpandey3341 3 ปีที่แล้ว

    *NOTES*

  • @romangaming5177
    @romangaming5177 2 ปีที่แล้ว

    //Whats wrong in this code
    #include
    using namespace std;
    struct node{
    int data;
    node* left;
    node* right;
    node(int val){
    data =val;
    left=NULL;
    right=NULL;
    }
    };
    int position(int inor[],int start, int end, int curr){
    for(int i=start;iend){
    return NULL;
    }
    static int idx=0;
    int curr =pre[idx];
    idx++;
    node* n1=new node(curr);

    if(start==end){
    return n1;
    }
    int pos =position(inor,start,end,curr);
    n1->left=build_tree(pre, inor, start, pos-1);
    n1->right=build_tree(pre, inor, pos+1, end);
    return n1;
    }
    void inorder(node* root){
    if(root==NULL){
    return;
    }

    inorder(root->left);
    cout

    • @ashutoshsharma4420
      @ashutoshsharma4420 2 ปีที่แล้ว +1

      nathing just input you taken is different so your output is diff
      if you take the same value 12435 then the answer will be same

    • @murarichaudhary5602
      @murarichaudhary5602 ปีที่แล้ว

      @@ashutoshsharma4420 use these values in preorder

  • @mehreenzia9515
    @mehreenzia9515 2 ปีที่แล้ว

    plz send code

  • @namansharma1448
    @namansharma1448 3 ปีที่แล้ว +1

    I m getting segmentation error can someone help me

    • @pranjalbajpai156
      @pranjalbajpai156 3 ปีที่แล้ว

      there might be a fault in segment i.e not writing == or stufs like that

    • @sparshtaneja
      @sparshtaneja 3 ปีที่แล้ว

      define the static indx outside the class as a global variable

    • @ROHITKUMAR-pn4gj
      @ROHITKUMAR-pn4gj 3 ปีที่แล้ว

      @@sparshtaneja but what's the reason behind this
      why static int is giving segmentation error

    • @gauravupreti9340
      @gauravupreti9340 3 ปีที่แล้ว

      @@ROHITKUMAR-pn4gj I am not getting this error, can you share your code, if you are having this error.

  • @karanagrawal8034
    @karanagrawal8034 3 ปีที่แล้ว

    Can anyone please explain me how idx value is increasing as it is redeclare every time

    • @isheoran
      @isheoran 3 ปีที่แล้ว +5

      Because we are using static variable and this variable once initialised keep on increasing even in recursive call.
      You call google "static variable" for more clarification.

    • @karanagrawal8034
      @karanagrawal8034 3 ปีที่แล้ว

      @@isheoran ok got it tysm

    • @Shourya_performs
      @Shourya_performs 2 ปีที่แล้ว

      @@isheoran gr8 thnx

  • @vedantshrivastava8258
    @vedantshrivastava8258 3 ปีที่แล้ว +1

    Hello I want to know is there any update regarding Java Placement Course ...

  • @bdar-yf4vl
    @bdar-yf4vl 2 ปีที่แล้ว

    code link

  • @divashreeagarwal8900
    @divashreeagarwal8900 2 ปีที่แล้ว

    I am getting a segmentation fault. Anyone knows how to fix it??

    • @pratikbhagat4670
      @pratikbhagat4670 ปีที่แล้ว

      it is because of declaring i=0 in buildtree function
      instead pass it in function

    • @Tommyshelby602
      @Tommyshelby602 ปีที่แล้ว

      Yes it works 🙏🏻

  • @sahilshende
    @sahilshende 3 ปีที่แล้ว +14

    Not intuitive, frankly.

  • @devenderrathour3749
    @devenderrathour3749 2 ปีที่แล้ว

    Please provide notes earlier

  • @ash-faque
    @ash-faque 3 ปีที่แล้ว +1

    What is the beat at the start ?🥺

  • @kishan2
    @kishan2 3 ปีที่แล้ว +1

    this is tough

  • @ritik51
    @ritik51 3 ปีที่แล้ว

    why without static right output do not come

    • @rahul_ji21
      @rahul_ji21 3 ปีที่แล้ว

      I m not sure but because of recursion I guess.every time the recursion statement is called, the index will start from 0 and will result in wrong ans . So the keyword static keeps the value of idx static throughout the program

    • @sajankumarkar8237
      @sajankumarkar8237 3 ปีที่แล้ว +1

      A variable when declared static, its value persists through the function calls. For example in this case idx is initialized with 0 and then incremented. So now before calling the function idx is 1. After the function is called idx value is not initialized to 0 again because it is declared static. Now when idx is incremented its value becomes 2.....
      If it was not declared static everytime the function was called its value would begin from 0 and would never become more than 1 in this case.

    • @ritik51
      @ritik51 3 ปีที่แล้ว +1

      @@sajankumarkar8237 why we are not using call by reference instead of static

    • @gauravupreti9340
      @gauravupreti9340 3 ปีที่แล้ว

      @@ritik51 Do you mean calling idx by reference, if yes then you can do this, you can even use call by value.

    • @anirudhmarutheri5094
      @anirudhmarutheri5094 3 ปีที่แล้ว

      but when using call by reference , i am getting an extra 4 (for the example in the video) in the end , any idea why ?

  • @sahillabhshetwar2739
    @sahillabhshetwar2739 2 ปีที่แล้ว

    you always miss something in the code and add it at the last , which makes it confusing . for example the return node in the last. try to write the code in one flow please.

    • @baidyanathroy7726
      @baidyanathroy7726 2 ปีที่แล้ว

      Do you even write codes in flow or you takes 3 days to write a code?

  • @shantanuhiwrale9843
    @shantanuhiwrale9843 3 ปีที่แล้ว

    lecture is really good but why notes are not there

  • @dhruvkumar4326
    @dhruvkumar4326 3 ปีที่แล้ว

    plz

  • @arzitmahajan7703
    @arzitmahajan7703 3 ปีที่แล้ว

    include
    #include
    using namespace std;
    struct Node{
    int data;
    struct Node*left;
    struct Node*right;
    Node(int val) {
    data = val;
    left = NULL;
    right = NULL;
    }
    };
    int search(int inorder[], int start, int end, int curr) {
    for (int i = start; i

    • @SajjadAhmed-lc2dr
      @SajjadAhmed-lc2dr 2 ปีที่แล้ว

      preorder ki sequence galat likhi hai apany

  • @dhruvkumar4326
    @dhruvkumar4326 3 ปีที่แล้ว +1

    apne paagal bnadia hmaraa...pyhton ka adha course upload kia h

    • @dhruvkumar4326
      @dhruvkumar4326 3 ปีที่แล้ว

      @@adityapai5147 abbe oo chilgozee....jaa kr videos dekh whaa 1 feb ko akhri lecture aya thaa////nd hme starting m kya bolla ki april tk compete hojaygaa....agr course adha krwana thaa too jaroorat kya thii///

    • @rishitiwari6200
      @rishitiwari6200 3 ปีที่แล้ว

      @@dhruvkumar4326 Tere koi naukar nhi lga h ya paisa nhi dia h tune ki koi tujhe pdhaye woh apne pace se pdhayenge baaki jyada jaldi h toh resources ki kmi nhi h intellipat dekh le utube be 10 ghnte ka lecture h complete python

    • @dhruvkumar4326
      @dhruvkumar4326 3 ปีที่แล้ว +1

      ​@@rishitiwari6200 abbbe oo gadhee///imp y nhi h course adha h ya pura//imp y h commitement kbhi puri nhi krte bhaiya.....python k course ka akhri video dekh kbb aya tha....oor phelaa dekh jha bhaiya bolrhe h 1st april tk khtm krwadenge.....oor teri jankari k lie btauu unacademy pr m plus subscriber hu or aman bhaiya s phy padhta hu...woohh 26 jan k baad hmari class lene ayee hi nhii....hamara sylaabus bechh m chordkrr chlegyee oor hzarooo bacho k future ko khrabb krdia

    • @dhruvkumar4326
      @dhruvkumar4326 3 ปีที่แล้ว

      @@rishitiwari6200 abbe oo bhuuto ko smjhagya h bhaiya fraud h///unacademy prr m plus subsrbier huu...mtlb fees bharta hu......wha pr bhaiya hmara pagaal bnagyee//akhri class hmarii 26 jan ko thi phy ki///hmara syllabus bacha hua h///ndd wohh ahi nhi rhe h tbsee....naahi kuch btarhe h////fraud h bhaiyaa

    • @rishitiwari6200
      @rishitiwari6200 3 ปีที่แล้ว +4

      @@dhruvkumar4326 jaa bhai tu logon ko iske fraud hone ka certificate bech bhai itna time waste mat kr aur jitna jaldi ho ske Pdhle aise logon ka committment dekhne baithega toh kuch na kr paega aur kisi ke upr dependent mt hua kr

  • @DINESHCHANDRA-hf1fi
    @DINESHCHANDRA-hf1fi 3 ปีที่แล้ว +2

    #include
    using namespace std;
    class Node
    {
    public:
    int data;
    Node* left;
    Node* right;
    Node(int val)
    {
    data = val;
    left = NULL;
    right = NULL;
    }
    };
    int search(int inorder[], int start, int end, int curr)
    {
    for(int i = start; i end)
    {
    return NULL;
    }
    int curr = preorder[idx];
    idx++;
    Node* node = new Node(curr);
    if(start == end)
    {
    return node;
    }
    int pos = search(inorder, start, end, curr);
    node->left = buildTree(preorder,inorder,start,pos-1);
    node->right = buildTree(preorder,inorder,pos+1,end);
    return node;
    }
    void inorderprint(Node* root)
    {
    Node* temp = root;
    if(temp == NULL)
    {
    return;
    }
    inorderprint(temp->left);
    coutn;
    int preorder[] = {1,2,4,3,5};
    // for(int i=0; i>preorder[i];
    // }
    int inorder[] = {4,2,1,5,3};
    // for(int i=0; i>inorder[i];
    // }
    Node* root = buildTree(preorder,inorder,0,4);
    inorderprint(root);
    }
    output : 2 4 3 1 5 0
    it's showing wrong. In which line, I am doing wrong

    • @anumoynandy5811
      @anumoynandy5811 3 ปีที่แล้ว

      In Search function loop continues till end i.e for(int i=start;i

  • @stylishstarrohan9616
    @stylishstarrohan9616 2 ปีที่แล้ว

    notes plz