Тёмный

L33. Requirements needed to construct a Unique Binary Tree | Theory 

take U forward
Подписаться 595 тыс.
Просмотров 84 тыс.
50% 1

Entire DSA Course: takeuforward.org/strivers-a2z...
Check our Website:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
#treeSeries #striver #placements

Опубликовано:

 

30 авг 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 96   
@takeUforward
@takeUforward 2 года назад
Please likeeee, shareeee and subscribeeeeeeee :) Also follow me at Insta: Striver_79
@amishasahu1586
@amishasahu1586 2 года назад
Understood sir!!!
@piyushacharya7696
@piyushacharya7696 Год назад
// 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
@nagame859 8 месяцев назад
thanks, sir.
@ritikshrivastava9442
@ritikshrivastava9442 8 месяцев назад
one more thing to note u can construct unique bt only when all the values in bt is unique
@rishabhgupta1222
@rishabhgupta1222 15 дней назад
@@ritikshrivastava9442 nope it depends on node's address and not value
@sanchitsanyam7359
@sanchitsanyam7359 Месяц назад
Really Bhaiya , your effort means allot to Student community, Your videos are awesome.
@stith_pragya
@stith_pragya 7 месяцев назад
Thank You So Much for this wonderful video..................🙏🙏🙏
@aswinikumarsahoo6459
@aswinikumarsahoo6459 Год назад
Recalled @Jenny's lectures CS/IT NET&JRF suddenly after 2 years, seeing the concept.
@shauryatomer1058
@shauryatomer1058 Месяц назад
thanks for the great content
@priyanshkumariitd
@priyanshkumariitd 4 месяца назад
thanks for awesome explanation striver bhaiya :)
@pratikmhatre4815
@pratikmhatre4815 8 месяцев назад
Very helpful
@bisssss21
@bisssss21 6 месяцев назад
the best teacher
@anonymousvoid6356
@anonymousvoid6356 2 года назад
This guy has the same enthusiasm in all videos!
@SHASHANKRUSTAGII
@SHASHANKRUSTAGII 2 года назад
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
@niranjansaha5135
@niranjansaha5135 Год назад
if it is a perfect binary tree, then with a single order traversal we can construct the tree. Am I saying anything wrong???
@parthsalat
@parthsalat Год назад
By perfect, you mean a complete binary tree, right?
@parthsalat
@parthsalat Год назад
@@niranjansaha5135 I guess, you are right
@SHASHANKRUSTAGII
@SHASHANKRUSTAGII Год назад
@@parthsalat right
@rishabhgupta1222
@rishabhgupta1222 15 дней назад
@@parthsalat no its wrong both are different
@user-tk2vg5jt3l
@user-tk2vg5jt3l 3 месяца назад
Thank you Bhaiya
@judgebot7353
@judgebot7353 8 месяцев назад
thanks
@ANURAGSINGH-nl2ll
@ANURAGSINGH-nl2ll 8 месяцев назад
Understand
@KartikeyTT
@KartikeyTT Месяц назад
tysm sir
@vivekreddy820
@vivekreddy820 4 месяца назад
understood sir
@avanishmaurya2034
@avanishmaurya2034 5 месяцев назад
Nice
@abhinanda7049
@abhinanda7049 Месяц назад
understood
@cinime
@cinime Год назад
Understood! Such an amazing explanation as always, thank you very much!!
@UjjawalSaran
@UjjawalSaran 24 дня назад
🔥
@anshulbhardwaj2666
@anshulbhardwaj2666 2 года назад
i best understood the concept from your videos sir thank you
@animeshmaru16
@animeshmaru16 2 года назад
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 🙂
@ShivamJha00
@ShivamJha00 Год назад
bruh
@tarun_sahnan
@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
@Yash-uk8ib
@Yash-uk8ib 2 года назад
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??
@sparshsharma6068
@sparshsharma6068 2 года назад
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-uk8ib
@Yash-uk8ib 2 года назад
@@sparshsharma6068 i think u have got a point!! Agreed!! Thanks for ur kind reply.
@sparshsharma6068
@sparshsharma6068 2 года назад
@@Yash-uk8ib Happy to help😊
@vibhu613
@vibhu613 2 года назад
@@sparshsharma6068 great Explaination
@sparshsharma6068
@sparshsharma6068 2 года назад
@@vibhu613 Thanks😄
@atharvakulkarni2024
@atharvakulkarni2024 2 года назад
Excellent Explanation!!!
@DilpreetSingh-cs7yz
@DilpreetSingh-cs7yz 2 года назад
why the inorder traversal along with any one of the remaining two traversals gives a unique binary tree and why not any other combination??
@priyanshkumariitd
@priyanshkumariitd 3 месяца назад
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.
@poojabennabhaktula4883
@poojabennabhaktula4883 2 года назад
Kudos to your effort!
@nileshsinha7869
@nileshsinha7869 2 года назад
Gonna complete the series tonight
@sangdilbiswal30
@sangdilbiswal30 10 дней назад
Hell yeah
@editorera239
@editorera239 2 года назад
Thanks bro for prior explanation
@lavanyaprakashjampana933
@lavanyaprakashjampana933 Год назад
we love your content and we love you.....🖤
@Professor-du2pf
@Professor-du2pf 5 месяцев назад
"US"
@momilijaz271
@momilijaz271 2 года назад
great tip!
@nagavedareddy5891
@nagavedareddy5891 2 года назад
Huge respect ❤👏
@amitswami3139
@amitswami3139 2 года назад
Very Good content striver
@user-jg2me8ry7l
@user-jg2me8ry7l Год назад
you are just amazing sir
@srivatsa1193
@srivatsa1193 2 года назад
this is awesome !
@tanyagupta4247
@tanyagupta4247 2 года назад
understood!
@SatyamEdits
@SatyamEdits Год назад
Hi Tanya ...!! Nice to see you ...again...!!! if you remember.....😅
@tanishsharma5440
@tanishsharma5440 Год назад
Excellent Bro, perfect
@alesblaze4745
@alesblaze4745 Год назад
thanks mate!
@bhaveshkumar6842
@bhaveshkumar6842 2 года назад
Thank you bro!!
@pawankumarpandit1822
@pawankumarpandit1822 Год назад
thank you striver bhaiya
@shivangisrivastava1158
@shivangisrivastava1158 2 года назад
Amazing 👏👏
@Ayush-lq3fz
@Ayush-lq3fz 2 года назад
understood :)))
@naman_goyal
@naman_goyal 2 года назад
Best content brother
@cricketjanoon
@cricketjanoon Год назад
Undersstod! 👍
@jaiminsolanki5478
@jaiminsolanki5478 2 года назад
Understood!
@vagabondfoodie5788
@vagabondfoodie5788 Год назад
Done till now 🥺🥺🥺 thankyou striver ❣️❣️
@parthsalat
@parthsalat Год назад
Understood kaka
@Anonymous-uj3jx
@Anonymous-uj3jx 2 года назад
Thanks :)
@UECAshutoshKumar
@UECAshutoshKumar 10 месяцев назад
Thank you sir
@BG-lj6fw
@BG-lj6fw Год назад
understood.
@Sumeet_100
@Sumeet_100 Год назад
Keep making this videos bhaiya
@sujan_kumar_mitra
@sujan_kumar_mitra 2 года назад
Understood
@utkarshsharma6650
@utkarshsharma6650 2 года назад
understoooood
@user-up6sl2gq8p
@user-up6sl2gq8p 8 месяцев назад
................
@dreamyme543
@dreamyme543 Год назад
Understood:)
@mriduljain1981
@mriduljain1981 11 месяцев назад
completed lecture 33 of free ka tree series.
@stevefox2318
@stevefox2318 2 года назад
Bawaal🔥💪
@harshit8525
@harshit8525 Год назад
Striver Bhaiya zindabad!!!
@jayyy311
@jayyy311 Год назад
💚
@shreyasvishwakarma8979
@shreyasvishwakarma8979 2 года назад
noice video
@suvanshmahajan5902
@suvanshmahajan5902 Год назад
"us"
@09_himanshusingh44
@09_himanshusingh44 2 года назад
Wow waiting for this 👍
@DoCTeRSinS
@DoCTeRSinS 8 месяцев назад
boooooooooooooooooooooooooooooooooooooooom
@piyushacharya7696
@piyushacharya7696 Год назад
reach++
@peddikarthik7832
@peddikarthik7832 11 месяцев назад
what if all the nodes have same value then answer wont be unique
@yashgupta-fk3zc
@yashgupta-fk3zc 2 года назад
first :)
@ojasdighe991
@ojasdighe991 2 года назад
🔺🔺
@harshitjaiswal9439
@harshitjaiswal9439 4 месяца назад
understood
@abdulrazzak2934
@abdulrazzak2934 2 года назад
understood!
@aftabalam7103
@aftabalam7103 Год назад
Understood
@pratikshadhole6694
@pratikshadhole6694 Год назад
understood
@rishabhgupta9846
@rishabhgupta9846 Год назад
understood
@manojnavinjamuri5867
@manojnavinjamuri5867 Год назад
understood
@chinu_.16
@chinu_.16 Год назад
understood
@roopeshn3301
@roopeshn3301 Год назад
Understood
@VikasGupta-ok9lh
@VikasGupta-ok9lh Год назад
Understood
Далее
POV: Spain vs Italia
00:11
Просмотров 350 тыс.
Binary Search Algorithm - Computerphile
18:34
Просмотров 156 тыс.
Binary Search Animated
7:00
Просмотров 24 тыс.
L37. Morris Traversal | Preorder | Inorder | C++ | Java
23:50
Unique Binary Search Trees II - Leetcode 95 - Python
12:51
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
POV: Spain vs Italia
00:11
Просмотров 350 тыс.