Lecture 66: Construct a Binary Tree from InOrder/PreOrder/PostOrder Traversal

  Рет қаралды 177,147

CodeHelp - by Babbar

CodeHelp - by Babbar

Күн бұрын

In this Video, we are going to solve TREE Important Interview Questions.
There is a lot to learn, Keep in mind “ Mnn bhot karega k chor yrr apne se nahi hoga ya maza nahi aara, Just ask 1 question “ Why I started ? “
Discord Server Link: / discord
Course Flow: whimsical.com/dsa-4-placement...
Notes Link: drive.google.com/drive/folder...
Slides Link: drive.google.com/file/d/1HQBc...
Code Links: github.com/loveBabbar/CodeHel...
Questions Links:
- Construct a BT from Inorder/PreOrder traversal: practice.geeksforgeeks.org/pr...
- Construct a BT from PreOrder/PostOrder traversal:practice.geeksforgeeks.org/pr...
Do provide you feedback in the comments, we are going to make it best collectively.
Connect with me here:
Instagram: / lovebabbar1
Twitter: / lovebabbar3
Telegram Group Link: Love Babbar CODE HELP
telegram.me/lovebabbercodehelp
My Editor: rishu.rsing...
Intro Sequence: We have bought all the required Licenses of the Audio, Video & Animation used.
Timestamps:
00:00 - Question 1
02:53 - Approach
11:05 - Code
22:38 - Question 2
23:40 - Approach
27:20 - Code
#DSABusted #LoveBabbar

Пікірлер: 407
@srmtube2556
@srmtube2556 2 жыл бұрын
3 things I learn when I see this videos one is dsa concepts and other is consistency and commitment.
@inspiringzone12
@inspiringzone12 2 жыл бұрын
Absolutely right
@khushisrivastava357
@khushisrivastava357 Жыл бұрын
Hey are u there? actually i am not able to find the codes on the github link after lec 65..i think they are missing
@RohitSharma-vq7ro
@RohitSharma-vq7ro Жыл бұрын
​@@khushisrivastava357bro itna to khud try kar
@MSDHONI___
@MSDHONI___ 11 ай бұрын
consistency is important bro
@top10shorts21
@top10shorts21 Жыл бұрын
The code mentioned in the video doesn't passes updated testcases --> So here is the updated code --> class Solution{ private: int Findposition(int in[] ,int inorderStart , int inorderEnd , int element ,int n){ for(int i = inorderStart ; i=n || inorderStart>inorderEnd){ return NULL ; } int element = pre[index++] ; // At every interation index is increasing Node* root = new Node(element); int position = Findposition(in , inorderStart , inorderEnd ,element, n); root->left = solve(in , pre , index , inorderStart , position-1 ,n); root->right = solve(in , pre , index , position+1 , inorderEnd ,n); return root ; } public: Node* buildTree(int in[],int pre[], int n) { // Code here int preorderindex = 0 ; //Pre order is NLR so First element is root . Node* ans = solve(in , pre , preorderindex , 0 , n-1 , n ); return ans ; }
@sourabhvishnoi9884
@sourabhvishnoi9884 Жыл бұрын
Really helpful, thanks
@anmol3
@anmol3 Жыл бұрын
Thanks
@vimalrai2092
@vimalrai2092 Жыл бұрын
it really helps, i was soo confused. thanks...
@AmitSharma-nv2oj
@AmitSharma-nv2oj Жыл бұрын
@@vimalrai2092 for which question
@khushdesai7600
@khushdesai7600 Жыл бұрын
can u tell us what you have change in this code?? because i have see this couple of time but , i could not catch it??
@anmol3
@anmol3 Жыл бұрын
Question 1 Test case 54 fails after addition of new test case Solution: Can't use maps. Use findPosition function and pass inorderStart and inorderEnd as arguments and not n(size). This happens because elements might be repeated.
@yashbanka8877
@yashbanka8877 Жыл бұрын
There is something wrong with this concept let me just clear it up . When you check for the location of the element in the inorder array you need not check it's location by traversing in the whole array instead , you need to check for the element in the required portion . In this case check for the element from in[inOrderStartIndex] to in[inOrderEndIndex] and you will just be fine
@shwetpatel2712
@shwetpatel2712 Жыл бұрын
Thanks Bro it works.
@PriyanshuSrivastava11fig
@PriyanshuSrivastava11fig Жыл бұрын
@@shwetpatel2712 please share the updated code. I'm not able to figure it out how to pass 54th test case using map
@shwetpatel2712
@shwetpatel2712 Жыл бұрын
@@PriyanshuSrivastava11fig sure here it is. class Solution{ public: int findposition(int element , int in[] , int start , int end) { for(int i = start ; i = n || inorder_start > inorder_end) { return NULL; } int element = pre[preorderindex]; Node* root = new Node(element); int position = findposition(element,in ,inorder_start , inorder_end); preorderindex++; root->left = solve(in,pre,n,preorderindex, inorder_start , position - 1); root-> right = solve(in , pre , n , preorderindex, position + 1 , inorder_end); return root; } Node* buildTree(int in[],int pre[], int n) { int preorderindex = 0; Node* temp = solve(in,pre,n, preorderindex, 0 , n-1); return temp; } };
@praveshishere
@praveshishere 3 ай бұрын
bro what would happend if elements are repeated in between inroderStart and inorderEnd
@anuragpandey8165
@anuragpandey8165 2 жыл бұрын
30:15 You clearly have a strong understanding about where the students could get stuck. Much love
@aayushiagarwal8797
@aayushiagarwal8797 Жыл бұрын
Thank you sir :), for making tree simple and understandable . I would like to highlight one point : Mapping solution will give wrong answer in case of duplicated nodes..... in such case , we can optimize findpos() function by checking from inStart to inEND .. int findpos(int in[],int x,int n,int s,int e) { for(int i=s;i
@ritikrastogi6438
@ritikrastogi6438 Жыл бұрын
Yes you're right
@govindsuryavanshi6653
@govindsuryavanshi6653 11 ай бұрын
First I have completed all DSA series and now conclude this is Greatest ever DSA series to exist on youtube or paid courses. Your contribution will be remembered. You're God of DSA for us🙇‍♂ Thanks you.
@rishiagarwal813
@rishiagarwal813 7 ай бұрын
bro 65th lecture ke bad GitHub par code links nhi hai ky ??
@prerakagarwal5623
@prerakagarwal5623 2 жыл бұрын
You are doing literally a very good job. I got to understand many concepts easily after watching your videos. Trees are very well explained. Many Thanks.
@kritarthtripathi9793
@kritarthtripathi9793 2 жыл бұрын
Best DSA course and consistency ++...Thank u so much for your effort❤
@simplesolutions2621
@simplesolutions2621 2 жыл бұрын
Best course! Best teacher! *Best time to learn!* 🔥
@sudhanshukumar3976
@sudhanshukumar3976 Жыл бұрын
mid course me kon coad dana band kar data hai ghanta best teacher
@prashantbirajdar9271
@prashantbirajdar9271 2 жыл бұрын
wah bhaiyaa ..another an exciting session i understood every thing from this session thanks bhiyaa for providing free of cost DSA course...loves the most...content and your teaching technique is so optimistic...thanks again
@yadvibhalla5392
@yadvibhalla5392 2 жыл бұрын
Best course ever🔥 consistency++;
@pavanmutalikdesai6611
@pavanmutalikdesai6611 2 жыл бұрын
Best explanation!!! You make solutions look so simple.
@chandrabhanbahetwar9638
@chandrabhanbahetwar9638 2 жыл бұрын
It is the best dsa course in the you tube bhaiya carry on we all are with you 🌹🌹
@rampratapmishra5962
@rampratapmishra5962 2 жыл бұрын
Wahh... Bhaiya mann gya aapko.. Kya consistency ha aapkee.. Ham ek video dekh nhi paarahe.. Aur aapke... New video... Aa rahe.. Ha bhaut saahi bhaiya.. Bass.. Aise hee consistentsy ham bhi continue kar paaye... Great bhaiya really great fan of you!!!!!! 🤗🤗
@ayushkiledar4730
@ayushkiledar4730 Жыл бұрын
Awesome!! The best DSA anyone can teach!!
@prabhatmishra6753
@prabhatmishra6753 2 жыл бұрын
Great Efforts Sir....I think who wants to learn tree this is the platform
@ritendrasinghbhadauriya5751
@ritendrasinghbhadauriya5751 2 жыл бұрын
Sir apke efforts to wakai sir excellent and ek aur best cheez ki aap scratch se har cheez samjhate hai........and sir salute to your consistency........💯💯
@ayushjangid5649
@ayushjangid5649 2 жыл бұрын
One of the best teacher || mentor. Thank you so much bhaiya for this course literally the best course.
@nishankdas1895
@nishankdas1895 Жыл бұрын
Amazing observation bro on the inorder to postorder question. I have never thought it that way.
@KPCoder
@KPCoder 2 жыл бұрын
Thanks you sir, excellent content, no one can explain like you from basic 🙏 god bless you
@rohanyadav2056
@rohanyadav2056 Жыл бұрын
Sir many many thanks to you You're an inspiration , I've referred this playlist to all my friends. Your dedication is next level sir
@haiderali0801
@haiderali0801 2 жыл бұрын
The best DSA course ✨❤️
@scoc55vora15
@scoc55vora15 Жыл бұрын
A Very WELL EXPLANATION wala Video and Insane amount of Effort of Love Bhaiya is clearly vivble and For that Again and Again Explanation Thank you bhaiya
@ankitgaur7428
@ankitgaur7428 2 жыл бұрын
Bhai Lecture 66 onwards code ko github mai push kyo nhi kar rhe ho? Repo se code samajna easy rehta hai. during videos hum code samaj sakte and then after completion of video hum code repo se notedown kar sakte hai. so pls push code from lecture 66 onwards in github repo.
@fahadnazir8924
@fahadnazir8924 Жыл бұрын
is Source-code of lecture 66 onwards available anywhere ?
@shrajangupta8206
@shrajangupta8206 Жыл бұрын
did you got any sourse where codes are there this lecture onwards?
@harpratapsinhnakoom3540
@harpratapsinhnakoom3540 2 жыл бұрын
words are not enough to express our gratitude towards you.. Thank you bhaiya
@Amaan-ji4su
@Amaan-ji4su Жыл бұрын
Best DSA course on youtube !
@shivkumar-og4ow
@shivkumar-og4ow 2 жыл бұрын
thank you bhaiya .. you are doing regularly hardwork to complete this course .. bahut bahut dhanybad.. ❤💘💘💘💘
@iqfacts8647
@iqfacts8647 8 ай бұрын
Best dsa course I have ever seen
@ritikamehta9791
@ritikamehta9791 2 жыл бұрын
Great consistency sir💯💯. Thank youu vry much!!
@AA-wy9vw
@AA-wy9vw 2 жыл бұрын
Loving the series!!
@satwiksharma4359
@satwiksharma4359 2 жыл бұрын
Great series , very helpful .
@anuragmalviya2397
@anuragmalviya2397 2 жыл бұрын
Bhaiya ki knowledge, video uploading me consistency, or way of explanation top notch hai!🔥🔥🔥
@user-lk1jv9qv4s
@user-lk1jv9qv4s Ай бұрын
Totally agreed
@vinayakgarg4628
@vinayakgarg4628 2 жыл бұрын
Here we can also use unordered map (T.C - O(1)) as we don't need data to be sorted, so the overall t.c will be O(n)
@deepakpal2168
@deepakpal2168 Жыл бұрын
Bro it will not work if we have dublicate values in array like (1 2 3 4 3)
@himanshukashyap8894
@himanshukashyap8894 2 жыл бұрын
keep growing bhaiya. You do wonderful for us
@someshsangwan3768
@someshsangwan3768 2 жыл бұрын
Op consistency bhaiya 👍🔥🔥🔥
@rashmi_gaur
@rashmi_gaur 2 жыл бұрын
Awesome Explanation!
@aishwaryaporwal2321
@aishwaryaporwal2321 2 жыл бұрын
I just solving this question from ur DSA sheet n got this video notification ♥️♥️💯
@faizanalam8360
@faizanalam8360 2 жыл бұрын
Loved your efforts. Thank you bhaiya
@ani68
@ani68 2 жыл бұрын
Was waiting for this one......💯💯💯💯
@shaleenspeaks003
@shaleenspeaks003 2 жыл бұрын
The best best best and best course ever
@dewanshpatle9056
@dewanshpatle9056 2 жыл бұрын
Best course ever consistency++;
@siddharthyadav1885
@siddharthyadav1885 Жыл бұрын
great work and effort
@prateeksharma3680
@prateeksharma3680 2 жыл бұрын
Attendance marked 👍👍👍 consistency 🔥🔥🔥
@ShailendraSingh-ob7rp
@ShailendraSingh-ob7rp 2 жыл бұрын
Thank you bhaiya Maza aa gya questions solve krke ✌️✌️
@parassetia4964
@parassetia4964 2 жыл бұрын
Lot of love to you bhaiya, hope you are well and fine. Just waiting for graphs and dp too😅
@utkarshsingh1457
@utkarshsingh1457 2 жыл бұрын
consistency op... Thanks for the beautiful content...Just enjoyed going through the lectures one by one... 😁
@deepak44222
@deepak44222 Жыл бұрын
mehnat lag raha hai bhai tum enjoy kaise kar le rahe ho.🥺🥺🥺🥺
@uditpanjiyar3203
@uditpanjiyar3203 10 ай бұрын
first question is explained very deeply but one more condition is also added on gfg that the values of root can be repeated thanks for the quality content
@ritesh_tiwari447
@ritesh_tiwari447 9 ай бұрын
for repeated nodes Just use map mpp and find element index by using {mpp[element].front()} then pop the queue
@KratosProton
@KratosProton 2 жыл бұрын
Great explaination!
@RahulKumar-wt9qc
@RahulKumar-wt9qc 2 жыл бұрын
Shaandar video hai bhaiya 👍👍👍
@keshavgambhir9894
@keshavgambhir9894 2 жыл бұрын
Present bhaiya Consistency op 🔥🔥🔥 Commenting for better reach
@suvigyabasnotra7378
@suvigyabasnotra7378 2 жыл бұрын
Can you give advice on what to do after seeing the solution of a problem you've never seen before and don't know how to code..?
@SanjuJana-pj6pn
@SanjuJana-pj6pn 11 ай бұрын
Thanks a lot bhaiya 😊❤
@rohitrohra7553
@rohitrohra7553 Жыл бұрын
u make everything simple
@shekharsuman3219
@shekharsuman3219 2 жыл бұрын
Bhaiya keep inspiring us we r with u
@muhammadsuleman8936
@muhammadsuleman8936 11 ай бұрын
Lecture was amazing brother
@curiosityOnItsPeak
@curiosityOnItsPeak 2 жыл бұрын
I used to get scared from some of questions including these But now .....Huhh! . All thanks to you bhaiya
@ekanshsharma1309
@ekanshsharma1309 Жыл бұрын
Simply Love You Bhaiya 💗💗
@gauravverma4652
@gauravverma4652 2 жыл бұрын
in first question u used map for optimisation which have complexity O(logn), shouldn't we use unordered_map for O(1) complexity ??
@Coder_DhruvArora
@Coder_DhruvArora 2 жыл бұрын
Yes
@sahilchhabra2391
@sahilchhabra2391 2 жыл бұрын
bhai dono me O(1) hogi na. Map ki key already pata h toh value toh yuhi nikal jaegi aur mp.find() use krne ki need nhi kyuki map toh bana hi saari entries se hai, key toh pakka hogi hi.
@Coder_DhruvArora
@Coder_DhruvArora 2 жыл бұрын
@@sahilchhabra2391 I didn't got your point But even inserting into map also takes O(log n) So it definitely adds into time complexity
@sahilchhabra2391
@sahilchhabra2391 2 жыл бұрын
@@Coder_DhruvArora oh I forgot about the insertion complexity for ordinary map 😅, ya ya u got that right
@7u5h42
@7u5h42 2 жыл бұрын
🙌🙌 consistency OP
@kunalbhika6424
@kunalbhika6424 3 ай бұрын
Great lecture as always😍
@rishabhjain7838
@rishabhjain7838 2 жыл бұрын
Dedication 😱💯💯
@amishapandey6875
@amishapandey6875 Жыл бұрын
Really THANKFULL!
@laksheybanga8106
@laksheybanga8106 2 жыл бұрын
Mzaa aa rha h bhaiyaaa 💕❤️
@Urahara25
@Urahara25 2 жыл бұрын
One suggestion bhaiya... We don't wanna get demotivated...so contest ke bhi solutions practice krwaiyega please......And company specific category bhi ki like kis site se kaun si kaun si company specific pdhna h... Interviewbit ,gfg,...etc...Amazon, Microsoft,google nd aur bhi
@harshpandey4190
@harshpandey4190 Жыл бұрын
Thankyou So much bhaiya going great
@alokranjan3185
@alokranjan3185 2 жыл бұрын
great explanation sir❤️
@niteshkoli007
@niteshkoli007 Жыл бұрын
ab ye question mai kabhi bhi nhi bhulne wala😁
@sunny-gb6xh
@sunny-gb6xh Жыл бұрын
Thank you bhaiya for your grt content :)
@janvi_jindal05
@janvi_jindal05 2 жыл бұрын
you are the best bhai....
@user-ey9lq4mf6p
@user-ey9lq4mf6p 5 ай бұрын
Thankyou Bhaiya!!
@adgurjar1663
@adgurjar1663 2 жыл бұрын
Best course 🔥🔥
@ziyadauti3676
@ziyadauti3676 7 ай бұрын
Best explanation compared to others...!
@Harshit-rm5kd
@Harshit-rm5kd Жыл бұрын
Thanks a lot bhaiya ❤❤
@user-ks8qn5sz5b
@user-ks8qn5sz5b 6 ай бұрын
code link from 66 lecture to end is not available sir , plzz upload the link the of code link. thank you from the bottom of my heart sir for making a beautiful series for us 😍😍
@yashzawar7938
@yashzawar7938 2 жыл бұрын
great job!!
@RajKumar-vq1nm
@RajKumar-vq1nm 2 жыл бұрын
Maza agaya..❤️
@RohitKumar-rm3kc
@RohitKumar-rm3kc Жыл бұрын
Amazing video 💛💛
@SanjuJana-pj6pn
@SanjuJana-pj6pn 11 ай бұрын
Thank you sir 😊
@bhavooksethi2589
@bhavooksethi2589 2 жыл бұрын
Best course❤
@PRIYANSHUKUMAR-un9zu
@PRIYANSHUKUMAR-un9zu 2 жыл бұрын
Present bhaiya🔥❤
@adarshparitosh5870
@adarshparitosh5870 2 жыл бұрын
Thank you so much bhaiya, before it I have been read 2,3 time but my concept was not clear but in first attempt I got 100℅ understanding of construct tree, ab mai DS se diprate ni ho rha😃ni to 4th sem me aa kar lgta tha khi CSE le kar galti to ni kr diye...
@theguywithdreams1600
@theguywithdreams1600 Жыл бұрын
Thankyou Bhaiya ❤
@AyushKumar-yu5tj
@AyushKumar-yu5tj 2 жыл бұрын
After this course Knowledge will be like knowledge= INT_MAX;
@BicornOfficial
@BicornOfficial 3 ай бұрын
lecture 66 onwards, the codes are not available on the github link mentioned in description. Where can i get those codes, does anyone have any idea?
@simplesolutions2621
@simplesolutions2621 2 жыл бұрын
Love _Consistency_ Babbar!
@sailendrachettri8521
@sailendrachettri8521 2 жыл бұрын
so far so good :)
@utkarshverma8773
@utkarshverma8773 2 жыл бұрын
ULTIMATE CONTENT
@aryapatel3495
@aryapatel3495 Жыл бұрын
awesome video❤
@aashishrangdal9614
@aashishrangdal9614 2 жыл бұрын
Deadline Seriously Le Rhe Ho Kya Bhaiyya😂 Consistant Level OP😁🥰
@Sam-rz5hw
@Sam-rz5hw Жыл бұрын
bhaiya aap best ho
@manishFromIT
@manishFromIT Жыл бұрын
Thanks bhaiya 👌
@swapnilsalunke5942
@swapnilsalunke5942 11 ай бұрын
Great work
@mansoorrr9167
@mansoorrr9167 Жыл бұрын
Can some tell me how in root left and right after giving range positions it is extracting the elements from inorder array? We are only finding the position of element from in order arr and passing the positions to recursion but how it is allocating the root left and right from the I order arr??
@yashgupta4866
@yashgupta4866 2 жыл бұрын
Present bhaiya Consistency OP
@savy9554
@savy9554 2 жыл бұрын
Amazing content
@harshalpatil6482
@harshalpatil6482 Ай бұрын
east or west babbar bhaiyya best
@bhuvamehulkumarvisabhai2904
@bhuvamehulkumarvisabhai2904 2 жыл бұрын
here in solve function why we sent map by address, because i try to sent by value and it gave me TLE
@verma_jay
@verma_jay Жыл бұрын
best course
@mightygerman
@mightygerman Жыл бұрын
Thnx a lot sir....
@shubhammanitripathi9507
@shubhammanitripathi9507 2 жыл бұрын
Maja aa gya 😁😍
Lecture 67: Minimum Time to BURN the Entire Binary Tree || C++ Placement Series
28:28
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 207 МЛН
MISS CIRCLE STUDENTS BULLY ME!
00:12
Andreas Eskander
Рет қаралды 20 МЛН
Coding Interviews Be Like
5:31
Nicholas T.
Рет қаралды 6 МЛН
SOLVE any DSA QUESTION using this 7-STEP Strategy
10:09
Love Babbar
Рет қаралды 61 М.
One Effective Trick to Learn Coding Fast (Works in 2024)
4:53
CodeWithHarry
Рет қаралды 295 М.
Lecture 65: Binary Tree FAANG Interview Questions || Part-3
59:15
CodeHelp - by Babbar
Рет қаралды 252 М.
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 207 МЛН