Please likeeee, shareeee and subscribeeeeeeee :) Also follow me at Insta: Striver_79
@amishasahu15862 жыл бұрын
Understood sir!!!
@piyushacharya76962 жыл бұрын
// NOTE: Q. How does inorder+preorder/postorder construct unique binary tree? -> Imagine that you have the following pre-order traversal: a,b,c,d,e,f,g. What does that tell you? You know that a is the root of the tree, this follows from the definition of a pre-order traversal. So far, so good. You also know that the rest of your list is the traversal of the left subtree followed by the traversal of the right subtree. Unfortunately you don't know where the split is. It could be that all of them belong to the left tree, it could be that all of them belong to the right tree, or b,c go left and d,e,f,g go right and so on. How to resolve the ambiguity? Well, let's take a look at the in-order traversal, what is its defining property? Any elements in the left subtree of a will come before a in the in-order traversal and any elements in the right subtree will come after a. Again, this follows from the definition of in-order traversal. So what we need to do is take a look at the in-order traversal (let's say it's c,b,a,d,e,f,g). We can see that b and c come before a, therefore they're in the left subtree, while d,e,f and g are in the right subtree. In other words, as position in the in-order traversal uniquely determines which nodes will be in its left/right subtrees. And this is great because we can now go on and solve the two subtrees recursively: pre-order b,c/in-order c,b and pre-order d,e,f,g/in-order d,e,f,g. And you can continue this recursively until all subtrees only contain a single element, where the solution is trivially unique. And since at each step we could prove that there is only one valid way to continue, the result is that a given pair of in-order and pre-order traversals can only belong to a single tree. NOTE: found this on Quora. It might help.
@nagame859 Жыл бұрын
thanks, sir.
@ritikshrivastava9442 Жыл бұрын
one more thing to note u can construct unique bt only when all the values in bt is unique
@rishabhgupta12225 ай бұрын
@@ritikshrivastava9442 nope it depends on node's address and not value
@SibiRanganathL27 күн бұрын
Dude loved the comment
@aswinikumarsahoo64592 жыл бұрын
Recalled @Jenny's lectures CS/IT NET&JRF suddenly after 2 years, seeing the concept.
@sanchitsanyam73596 ай бұрын
Really Bhaiya , your effort means allot to Student community, Your videos are awesome.
@animeshmaru162 жыл бұрын
One exception for this is.. If we have only one node in binary tree then we can construct unique binary tree from preorder and postorder traversal. Preorder: 1 Postorder: 1 Unique binary tree: 1 (Root node) Sounds like funny but we can explain this edge case in interview and can have more advantage 🙂
@ShivamJha002 жыл бұрын
bruh
@tarun_sahnan Жыл бұрын
if you have only one node that only there is no need for 2 traversal only one traversal will give you the solution. Preorder -> 10 10 is the root node
@haripriya803416 күн бұрын
excellent explanation
@SHASHANKRUSTAGII2 жыл бұрын
If you have a perfect binary tree, then given only the PREORDER and POSTORDER, you can construct your unique binary tree Source: NPTEL IIT DELHI, DR. Naveen Garg
@niranjansaha51352 жыл бұрын
if it is a perfect binary tree, then with a single order traversal we can construct the tree. Am I saying anything wrong???
@parthsalat2 жыл бұрын
By perfect, you mean a complete binary tree, right?
@parthsalat2 жыл бұрын
@@niranjansaha5135 I guess, you are right
@SHASHANKRUSTAGII2 жыл бұрын
@@parthsalat right
@rishabhgupta12225 ай бұрын
@@parthsalat no its wrong both are different
@stith_pragya Жыл бұрын
Thank You So Much for this wonderful video..................🙏🙏🙏
@anonymousvoid63562 жыл бұрын
This guy has the same enthusiasm in all videos!
@nileshsinha78693 жыл бұрын
Gonna complete the series tonight
@sangdilbiswal305 ай бұрын
Hell yeah
@Zombyyieeeeee11 ай бұрын
the best teacher
@priyanshkumar179 ай бұрын
thanks for awesome explanation striver bhaiya :)
@DeadPoolx17128 күн бұрын
UNDERSTOOD;
@pratikmhatre4815 Жыл бұрын
Very helpful
@apmotivationakashparmar72223 күн бұрын
Thank you so much!
@Yash-uk8ib3 жыл бұрын
sir, what is the reason behind the fact that the inorder traversal along with any one of the remaining two traversals gives a unique binary tree and why not any other combination??
@sparshsharma60683 жыл бұрын
I think that, Since In inorder traversal, we can identify the left and right subtrees of a node but, the same won't be true in the case of the remaining traversals. Consider the following tree: 1 / \ 2 3 / \ / \ 4 5 6 7 / \ / 8 9 10 Inorder traversal of this tree will be: [8,4,9,2,10,5,1,6,3,7] (LNR) postorder traversal of this tree will be: [8,9,4,5,2,6,7,3,1] (LRN) preorder traversal of this tree will be: [1,2,4,8,9,5,10,3,6,7] (NLR) Now, from this traversal, we can easily see that all the nodes on the left side of node 2 in the inorder traversal will form the left subtree. So that's why inorder along with post/preorder must give unique BTree.
@Yash-uk8ib3 жыл бұрын
@@sparshsharma6068 i think u have got a point!! Agreed!! Thanks for ur kind reply.
@sparshsharma60683 жыл бұрын
@@Yash-uk8ib Happy to help😊
@vibhu6132 жыл бұрын
@@sparshsharma6068 great Explaination
@sparshsharma60682 жыл бұрын
@@vibhu613 Thanks😄
@shauryatomer10586 ай бұрын
thanks for the great content
@Learnprogramming-q7f8 ай бұрын
Thank you Bhaiya
@judgebot7353 Жыл бұрын
thanks
@hitheshpk60303 ай бұрын
Understood
@avanishmaurya203410 ай бұрын
Nice
@atharvakulkarni20243 жыл бұрын
Excellent Explanation!!!
@ANURAGSINGH-nl2ll Жыл бұрын
Understand
@vivekreddy8209 ай бұрын
understood sir
@KartikeyTT6 ай бұрын
tysm sir
@UjjawalSaran5 ай бұрын
🔥
@harshitjaiswal94399 ай бұрын
understood
@sysfailureexe60384 ай бұрын
Thanks u
@poojabennabhaktula48832 жыл бұрын
Kudos to your effort!
@anshulbhardwaj26662 жыл бұрын
i best understood the concept from your videos sir thank you
@cinime2 жыл бұрын
Understood! Such an amazing explanation as always, thank you very much!!
@Professor-du2pf10 ай бұрын
"US"
@parthsalat2 жыл бұрын
Understood kaka
@editorera2393 жыл бұрын
Thanks bro for prior explanation
@mriduljain1981 Жыл бұрын
completed lecture 33 of free ka tree series.
@momilijaz2712 жыл бұрын
great tip!
@amitswami31392 жыл бұрын
Very Good content striver
@D44Aishwarya Жыл бұрын
you are just amazing sir
@UECAshutoshKumar Жыл бұрын
Thank you sir
@tanyagupta42473 жыл бұрын
understood!
@SatyamEdits2 жыл бұрын
Hi Tanya ...!! Nice to see you ...again...!!! if you remember.....😅
@DilpreetSingh-cs7yz2 жыл бұрын
why the inorder traversal along with any one of the remaining two traversals gives a unique binary tree and why not any other combination??
@priyanshkumar178 ай бұрын
Because we need to know not only the root but the left subtree & right subtree as well. So, one of the traversal should be inorder to identify UNIQUE BT.
@tanishsharma54402 жыл бұрын
Excellent Bro, perfect
@alesblaze47452 жыл бұрын
thanks mate!
@srivatsa11932 жыл бұрын
this is awesome !
@Sumeet_100 Жыл бұрын
Keep making this videos bhaiya
@lavanyaprakashjampana9332 жыл бұрын
we love your content and we love you.....🖤
@pawankumarpandit1822 Жыл бұрын
thank you striver bhaiya
@shivangisrivastava11582 жыл бұрын
Amazing 👏👏
@cricketjanoon Жыл бұрын
Undersstod! 👍
@vagabondfoodie5788 Жыл бұрын
Done till now 🥺🥺🥺 thankyou striver ❣️❣️
@BG-lj6fw Жыл бұрын
understood.
@nagavedareddy58912 жыл бұрын
Huge respect ❤👏
@Anonymous-uj3jx2 жыл бұрын
Thanks :)
@jaiminsolanki54782 жыл бұрын
Understood!
@bhaveshkumar68422 жыл бұрын
Thank you bro!!
@pratikshadhole6694 Жыл бұрын
understood
@utkarshsharma66502 жыл бұрын
understoooood
@naman_goyal3 жыл бұрын
Best content brother
@sujan_kumar_mitra3 жыл бұрын
Understood
@ajayypalsingh2 жыл бұрын
💚
@dreamyme5432 жыл бұрын
Understood:)
@SibiRanganathL27 күн бұрын
Comments
@Ayush-lq3fz3 жыл бұрын
understood :)))
@harshit8525 Жыл бұрын
Striver Bhaiya zindabad!!!
@shreyasvishwakarma89793 жыл бұрын
noice video
@peddikarthik7832 Жыл бұрын
what if all the nodes have same value then answer wont be unique