Count Number of Binary Search Tree Possible given n keys Dynamic Programming

  Рет қаралды 85,019

Tushar Roy - Coding Made Simple

Tushar Roy - Coding Made Simple

Күн бұрын

Пікірлер: 88
@mukhammadmuratov5715
@mukhammadmuratov5715 2 жыл бұрын
That is THE best explanation for this problem. For some reason I really struggled with this one and watched a lot of guides on youtube/leetcode discussion sessions, but could not get those. Here, after just conceptual explanation I stopped the video and was able to code solution on my own. Thank you SO much Tushar, great explanation and teaching, keep it up!
@m0rtale195
@m0rtale195 5 жыл бұрын
Great explanation! Helped me through a homework question asking for a similar algorithm.
@partheshsoni6421
@partheshsoni6421 3 жыл бұрын
You are the best DSA content providing channel. Thanks a lot!
@santhoshmedide5279
@santhoshmedide5279 3 жыл бұрын
I saw a couple videos and explanations for this question so far and this's been the best one out there.
@pl5778
@pl5778 5 жыл бұрын
this is the best explanation on youtube, thanks for this!
@prodev7401
@prodev7401 9 жыл бұрын
GO GO Tushar :))) the best channel
@rajeshkumarjha007raj
@rajeshkumarjha007raj 6 жыл бұрын
Hello friends. Coding karlo. Jokes apart, i appreciate your efforts, you'er a fabulous teacher. Keep growing.
@AK-fk8jv
@AK-fk8jv 6 жыл бұрын
haha lol
@fatihgul4027
@fatihgul4027 3 жыл бұрын
Great explanation
@sameergirkar
@sameergirkar 6 жыл бұрын
Very good video to understand this problem. Thanks Tushar.
@vinittodai911
@vinittodai911 2 жыл бұрын
Awesomest Explanation!
@lambdastudies3409
@lambdastudies3409 3 жыл бұрын
What a legend sir! Salute and thanks
@chrisogonas
@chrisogonas 3 жыл бұрын
Well illustrated. Thanks
@treksis
@treksis 3 жыл бұрын
still the best. video recorded in 2015.
@JJ-Bond
@JJ-Bond 5 жыл бұрын
but how tho? what are those two for loops from? It seems like a huge jump from the algo to the code. where's that thought process?
@bluemoonsri
@bluemoonsri 4 жыл бұрын
yes, he should have spent more time explaining the code
@ronki18
@ronki18 3 жыл бұрын
lol, guess you are just too dumb
@191sri
@191sri 6 жыл бұрын
Hi Tushar, Can you help to solve this kind of problem Question : Given a set of N numbers [1,N], partition them into 2 disjoint subsets based on a set of K queries. Each query is of the type (n1, n2) where n1 and n2 are distinct numbers from the set and n1 and n2 belong to opposite subsets. Example: Input: Input: N = 4 K = [(1, 2), (1, 3), (2, 4)] Output: Set 1 : (1,4) Set 2 : (2,3)
@create_space812
@create_space812 4 жыл бұрын
very clear! thank you Tushar!
@Yzhang250
@Yzhang250 7 жыл бұрын
Great great explanation of the answer, can you talk more about catalan number?
@SivaBhargavRavella
@SivaBhargavRavella 4 жыл бұрын
good explanation.
@ramkumarps185
@ramkumarps185 6 жыл бұрын
How did u arrive at the first and second for loop conditions and the formula T[j] * T[i-j-1] ? I could understand how the multiply works though but cannot understand the generalization here.
@executer77
@executer77 5 жыл бұрын
(2n)!/(n+1)!*n! ..............same here bro couldn't get the generalization and the formula as well.
@vigneshnaik7158
@vigneshnaik7158 5 жыл бұрын
Both left subtree and right subtree are linked. So if the number of structures of left subtree is x and number of right subtree structures is y. Then unique trees formed will be x*y. Suppose x=2 and y=2. Then I'll be having 4 different and unique tree structures ryt.
@bharathateja2797
@bharathateja2797 5 жыл бұрын
very nice explanation thanks
@ameyapatil1139
@ameyapatil1139 4 жыл бұрын
very well explained.
@jeetgandhi5629
@jeetgandhi5629 4 жыл бұрын
Amazing Solution! Thank you, sir!
@mubiale4060
@mubiale4060 4 жыл бұрын
Thanks, its clear to understand
@hjkc6000
@hjkc6000 5 жыл бұрын
Google should hire this man
@DheerajKumarBarnwal
@DheerajKumarBarnwal 5 жыл бұрын
He is an Engineering manager at Apple.
@m16biswas45
@m16biswas45 4 жыл бұрын
thank you so much.......
@prakashhiranandani
@prakashhiranandani 5 жыл бұрын
Thank You Sir!!! great help in understanding DP problems :) Keep it up!!!
@shobhitranjan3957
@shobhitranjan3957 4 жыл бұрын
brilliant!
@noornoorjahan4261
@noornoorjahan4261 2 жыл бұрын
you can simply use this formula( 2n! / (n+1)! X n!) and substitute the n value simple.
@siaw0000
@siaw0000 5 жыл бұрын
Very nice video! I've been trying to find answers to this question, but most sites I've come across only offer the answer with no explanation how they got there.
@RohanKumar-vx5sb
@RohanKumar-vx5sb 6 жыл бұрын
Tushar!!! Cant thank enough!!
@ashwinsubu5521
@ashwinsubu5521 5 жыл бұрын
Perfect explanation. What if you wanna display all the possible BSTs too? How would you handle that? Do you have a video for that?
@vikrant4666
@vikrant4666 5 жыл бұрын
he's doing job in apple now , he dont have time for ur shit now
@herbertzhou2598
@herbertzhou2598 3 жыл бұрын
awesome
@arnaudcortisse1041
@arnaudcortisse1041 4 жыл бұрын
"BST is a tree where every node has two child" --> I stopped there...
@windmaomao
@windmaomao 4 жыл бұрын
Well, you have to have some tolerance for common sense, which might not be mathematically accurate.
@suhanshupatel9204
@suhanshupatel9204 4 жыл бұрын
Thanku you!!
@swagatzeher
@swagatzeher 3 жыл бұрын
Superb explanation as always ! By the way I like your hairstyle :)
@AnuragGarg-dexter
@AnuragGarg-dexter 9 жыл бұрын
Great explanation. I have a doubt though. What happens if there are duplicate elements?
@hardikrana2649
@hardikrana2649 7 жыл бұрын
BST never have duplicates
@praffulmittal28
@praffulmittal28 6 жыл бұрын
Anurag Garg bro their is no duplicate item in bst.....
@skootergofast123
@skootergofast123 6 жыл бұрын
its 1 to n....so no duplicates
@lavishgarg4274
@lavishgarg4274 5 жыл бұрын
There are no duplicate element in the BST
@b9944236
@b9944236 Жыл бұрын
Best
@sarora8475
@sarora8475 2 жыл бұрын
wow thanks!
@Rajuvlogs9182
@Rajuvlogs9182 3 жыл бұрын
initially ,there was only one tree with value 2.find the total number of trees present after cutting k trees .input:1,input:5 and output :3 c++ program Pls tell me
@SnehasishGhoshSg
@SnehasishGhoshSg 5 жыл бұрын
Awesome Thhuusar..
@konstantinshalnev2173
@konstantinshalnev2173 6 жыл бұрын
Brilliant. Thanks.
@jinyi0313
@jinyi0313 6 жыл бұрын
how to calculate possible triangle in binary tree. example if i insert 7 points it will return 4 triangle. thank you for asnwer
@pranaytanniru7764
@pranaytanniru7764 5 жыл бұрын
Thank you
@kenrivkenriv5645
@kenrivkenriv5645 4 жыл бұрын
pretty good!
@ranjithcheguri
@ranjithcheguri 4 жыл бұрын
Thanks man.
@deepakpoojari9019
@deepakpoojari9019 4 жыл бұрын
great thanks man!!!!
@evgeny1555
@evgeny1555 4 жыл бұрын
What if some nodes have the same keys? For example 1, 1, 1, 2, 2, 2
@ashishjaiswal4207
@ashishjaiswal4207 4 жыл бұрын
we will on the left node
@ІванМанчур-е7з
@ІванМанчур-е7з 4 жыл бұрын
This is not possible - every key in BST must be unique
@artempar
@artempar 4 жыл бұрын
I tried both solutions that provided - and they both return wrong count. For n = 3 it returns 12, not 5.
@harishchandramohan1823
@harishchandramohan1823 5 жыл бұрын
If given numbers are 7,9,11 . There are 6 different BST possible. But u said for 3 elements only 5 bst possible how?
@SHASHANKRUSTAGII
@SHASHANKRUSTAGII 5 жыл бұрын
This was in my test series
@11m0
@11m0 8 жыл бұрын
Could u explain why we multiply instead of adding when a certain number is the root like at 4:53?
@abhishekpandey4427
@abhishekpandey4427 7 жыл бұрын
Permutations and combinations is the chapter you should study
@Majorchaoss
@Majorchaoss 4 жыл бұрын
multiplication is considering both possibilities happen together, addition implies either of the possibilities can happen.
@umarazahid6183
@umarazahid6183 4 жыл бұрын
what are the ways to search a nuber from a tree?
@Atpugtihsrah
@Atpugtihsrah 3 жыл бұрын
KZbin generated caption right said "Hello friends, my name is too sharp ... " 😀
@viraj_singh
@viraj_singh 7 жыл бұрын
great
@shairafghan4470
@shairafghan4470 6 жыл бұрын
R/Sir Please help me in completing my assignment Q1) what is running time of of algorithm. First write the recurrence equation and then find its complexity function(int n) { if (n
@koustavdas6585
@koustavdas6585 4 жыл бұрын
It is a catalan number. But how it come. Please derive the general rule
@shoebmoin10
@shoebmoin10 6 жыл бұрын
This can be done simply by finding the catalan number.
@meganlee5897
@meganlee5897 7 жыл бұрын
this is Catalan number.
@lavishgarg4274
@lavishgarg4274 5 жыл бұрын
Yes this can be implemented directly by formula, but understanding the app. is important, ie from where that formula has actually derived
@pseudonym033
@pseudonym033 6 жыл бұрын
miaoooooo I love Indian nerds
@nehasehta7762
@nehasehta7762 8 жыл бұрын
pl explain no of binary trees possible with n unlabeled or labeled nodes
@srijankumarsamanta5579
@srijankumarsamanta5579 5 жыл бұрын
www.geeksforgeeks.org/enumeration-of-binary-trees/
@sahukarinaveenkumar3188
@sahukarinaveenkumar3188 4 жыл бұрын
If we give n=384 it is giving wrong answer.. could anyone plz check
@virinchisavanapelli5898
@virinchisavanapelli5898 4 жыл бұрын
why t[0]=1?
@vaibhavchhabra800
@vaibhavchhabra800 8 жыл бұрын
+Tushar Roy I don't think it is a question of dynamic programming n there is a direct formula for this question Proof - www.geeksforgeeks.org/g-fact-18/
@easynet1yt
@easynet1yt 8 жыл бұрын
+Tushar Roy hahah..Made my day !!! I was just mugging up this formula. Your comment made me to watch whole video once again. Thanks for videos !! Subscribed !! :D
@AnantSF
@AnantSF 8 жыл бұрын
Memorization without memoization doesn't help. :)
@SundeepI9
@SundeepI9 5 жыл бұрын
2:38 what happened to 11 - 12 - 10
@capybara42069
@capybara42069 4 жыл бұрын
10 wouldn't be greater than 11
@umarazahid6183
@umarazahid6183 4 жыл бұрын
answer please hurry up?
Maximum Sum Increasing Subsequence Dynamic Programming
8:30
Tushar Roy - Coding Made Simple
Рет қаралды 81 М.
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 45 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 262 #shorts
00:20
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 41 МЛН
Help Me Celebrate! 😍🙏
00:35
Alan Chikin Chow
Рет қаралды 90 МЛН
Count Number of Binary Tree Possible given Preorder Sequence length dynamic programming
9:33
Tushar Roy - Coding Made Simple
Рет қаралды 32 М.
6. Binary Trees, Part 1
50:59
MIT OpenCourseWare
Рет қаралды 156 М.
Catalan Numbers - Numberphile
13:16
Numberphile
Рет қаралды 319 М.
Egg Dropping Dynamic Programming
11:17
Tushar Roy - Coding Made Simple
Рет қаралды 200 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 421 М.
Lowest Common Ancestor Binary Tree
11:08
Tushar Roy - Coding Made Simple
Рет қаралды 252 М.
Maximum Size Rectangle of All 1's Dynamic Programming
6:55
Tushar Roy - Coding Made Simple
Рет қаралды 181 М.
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 45 МЛН