Recursion tree method | Solving Recurrences | Data Structure & Algorithm | Gate Applied Course

  Рет қаралды 205,373

GATE Applied Course

GATE Applied Course

5 жыл бұрын

#gatecse #ds #algorithm #recursiontree #recurrences #appliedgate #gate2022
Subject Name: Data Structures and Algorithms
Chapter Name: Solving Recurrences
Topic Name: Recursion Tree
Please visit: gate.appliedroots.com/, interviewprep.appliedroots.com
For any queries you can either drop a mail to gatecse@appliedroots.com or call us at +91 844-844-0102
Refer: en.wikipedia.org/wiki/Geometr...

Пікірлер: 123
@mohamedsharif2269
@mohamedsharif2269 2 жыл бұрын
The best teachers are the passionate ones. Thanks for the contribution
@toddh2327
@toddh2327 Жыл бұрын
Nice. Just went over this in class and you explained it better in a fraction of the time. Appreciate the work!
@yashwantthombre9297
@yashwantthombre9297 4 жыл бұрын
"nothing very fancy here" i love this line sir! and really there is nothing very fancy actually......
@amaladiguna8873
@amaladiguna8873 3 жыл бұрын
I find myself smiling after learning this from you, thanks a lot!
@hammad8965
@hammad8965 3 жыл бұрын
same
@gopiazad677
@gopiazad677 2 жыл бұрын
Ek baar Reddy sir se padh k dekho.
@lunyi2671
@lunyi2671 3 жыл бұрын
best than any others. good to be teacher of cs
@persianwaffle
@persianwaffle 3 жыл бұрын
YOU'RE BREATHTAKING. THANK YOU
@lucascamino8615
@lucascamino8615 2 жыл бұрын
Thanks for sharing this! I found it very useful and well explained
@gello95
@gello95 3 жыл бұрын
Thank you so much!!! Magnificent explanation.
@Tanque95
@Tanque95 2 жыл бұрын
cn^2 is the time that takes to 'merge' the subproblems. And that is why T(n/4) = 3T(n/16) + c(n/4)^2 takes for each 3 subproblems c(n/4)^2 times 3 ===> 3/16 * cn^2.
@kenzou776
@kenzou776 4 жыл бұрын
thank you so much. this has helped a TON
@dynamicsid8795
@dynamicsid8795 3 жыл бұрын
One of best way to teach this topic👍♥️
@emirulusoy579
@emirulusoy579 3 ай бұрын
Thank you! I couldn't understand it in other people's videos, but this was very descriptive. You have a logic-based approach that is far from memorized.
@ajmalkhaniit
@ajmalkhaniit 4 жыл бұрын
Sir your explanation way is awesome!
@naitech9003
@naitech9003 4 жыл бұрын
Thanks for this bit of information!
@jatinsharma1915
@jatinsharma1915 3 жыл бұрын
In the geometric series, there are exactly log n base 4 terms. So why do we use infinite series formula here? Why not use the formula, Sum = a^m(r^m - 1)/(r+1), where m = number of terms in GP = log n base 4 in this example.
@kryddan
@kryddan 2 жыл бұрын
I think it is a simplification to get rid of the log_4(n) factor in the exponent of the result you get when you use the geometric sum formula. It is just a way to bound it (from above).
@chnihar4123
@chnihar4123 3 жыл бұрын
The best explanation I have ever witnessed.......hats off🙏
@criticalcommunist5
@criticalcommunist5 2 жыл бұрын
Kuch bhi ? master method is easy peasy.
@aris.konstantinidis
@aris.konstantinidis 3 жыл бұрын
thank you so much! pure gold
@jannatulshapna232
@jannatulshapna232 4 жыл бұрын
you saved my life .thank you
@akashprajapati1068
@akashprajapati1068 3 жыл бұрын
Shouldn't the root node be n^2?
@khalismurfid162
@khalismurfid162 3 жыл бұрын
OMG You just saved my life sir
@SumitKumar-ru7kb
@SumitKumar-ru7kb 4 жыл бұрын
Great Explanation.
@manaliredkar5057
@manaliredkar5057 3 жыл бұрын
Good job explaining!!
@lamaschool
@lamaschool Жыл бұрын
it is so nice thanks but i confused why you did not chosen the root cn square because you chose the root to be n only ?
@manishakhatri3369
@manishakhatri3369 2 жыл бұрын
I have some doubts as follows: 1. why we have not included log4n, and the final result would be n^2 log4n 2. The series should start from 3n/4 , 9n/16, .... so on, so in that case formula should change 3. why we have considered infinite series and why not finite(n) series?
@yevgeniydiriyenko4457
@yevgeniydiriyenko4457 2 жыл бұрын
because this picture is missing a little bit of data, at node one as you can easily see we start at n/4. thus T(n/4) = (n/4)^2. (we get this from the n^2 term) this represents the first step whilst it shows and looks like 3n/4 it's actually 3T(n/4) so do the math at the first part of this tree n/16 + n/16 + n/16 = 3n/16 next step is T(n/16) this results in (3n/16)^2 = 9n/16^2 this gives us the sum formula of (3/16)^i * n^2 *c once again look at the tree n/4 n/4 n/4 n/16 n/16 n/16 n/16 n/16 n/16 n/16 n/16 n/16 what's implied is: (n/4)^2 + (n/4)^2 + (n/4)^2 = 3n/16 at step one =(n/16)^2 + (n/16)^2 + (n/16)^2 , (n/16)^2 + (n/16)^2 + (n/16)^2 , (n/16)^2 + (n/16)^2 + (n/16)^2 again the reason you square is because the function seems to be order of n^2 at step two this results in: (3/16)^2 = total of 9 n^2 / 256 at next step: (3/16)^3 so on and so forth you get the idea (3/16)^n your confusion as well as mine initially must be from the part where he shouws step one with n/4 *cn^2 the right side should say 3/16*cn^2 and the step two where he has n/16*cn^2 should say (3/16)^2*cn^2
@mattn.8941
@mattn.8941 2 жыл бұрын
Based on my textbook and explanations from my professor, I think you're right and that this video is incorrect.
@rizwanmuhammad6468
@rizwanmuhammad6468 2 жыл бұрын
You mean 3 times (n^2)/16. And so on
@shashankjoshi8250
@shashankjoshi8250 6 ай бұрын
Hello Sir, Why it is not theta(n^2 logn_4) ? In merge sort we have nlogn_2
@kavitabhatt2811
@kavitabhatt2811 2 жыл бұрын
Great way of explaining anything....thanks a lot sir😊
@nirmalbisht9710
@nirmalbisht9710 2 жыл бұрын
❤️❤️ it's amazing
@pravalikabasam3370
@pravalikabasam3370 2 жыл бұрын
What about floor function? Why did we simply ignore it?
@ashifkhan
@ashifkhan 3 жыл бұрын
Bro you made my day 😍💥
@saisantoshvasamsetti3450
@saisantoshvasamsetti3450 8 ай бұрын
Will the recurrence tree method always give theta bound, or on which basis have u confirmed that it is. Theeta
@benjaminagyekum7283
@benjaminagyekum7283 5 күн бұрын
best explanation have been reading the Comen book but this is more like the comen book in a video form.
@Ashmole3
@Ashmole3 2 жыл бұрын
This was very helpful but why did you conclude that it was theta n^2 instead of O n^2?
@laszlomattern
@laszlomattern 7 күн бұрын
Thank you so much!
@parvathipradeep5218
@parvathipradeep5218 5 ай бұрын
Sir why we use theta here instead of other notations
@daniaayad5874
@daniaayad5874 4 ай бұрын
that was a very good video thanks alot
@muratcansenturk2275
@muratcansenturk2275 2 жыл бұрын
It is very simple, hello from Turkey
@nikitasinha8181
@nikitasinha8181 4 жыл бұрын
Thank u so much sir 🙏
@anamika9479
@anamika9479 3 жыл бұрын
Thanku so much finally I understand the whole thing..
@shriramrathod9074
@shriramrathod9074 3 жыл бұрын
ya right it's giving dam deep knowledge.
@tusharsharma6518
@tusharsharma6518 Жыл бұрын
But why did we find height of tree as we haven't used it....?
@rchtchauhan
@rchtchauhan 3 жыл бұрын
I am not getting the concept how cn^2 time to combine
@tusharverma2287
@tusharverma2287 3 жыл бұрын
Why did you used theta not Big O?
@devendramishra5872
@devendramishra5872 2 жыл бұрын
why you taken theta not big O or omega .
@laszlomattern
@laszlomattern 10 күн бұрын
Thank you !
@068_gauravchakraborty
@068_gauravchakraborty 2 жыл бұрын
great explanation sir
@karimahmed-xt1mj
@karimahmed-xt1mj 3 ай бұрын
in my class the +cn^2 part we don't substitute with n ,we keep it as it is for the whole problem
@user-tx3mo1ez2n
@user-tx3mo1ez2n 3 жыл бұрын
Very helpful.
@louerleseigneur4532
@louerleseigneur4532 4 жыл бұрын
Thanks sir ji
@digirocksstore2307
@digirocksstore2307 Жыл бұрын
At level 1 it took cn² the n²/16 at level 2 WHY???
@AnjaliSingh-yk9jv
@AnjaliSingh-yk9jv 3 жыл бұрын
Amazing.... In bihari style Garda 😍😍😍😍😍😍😍
@digirocksstore2307
@digirocksstore2307 Жыл бұрын
Why not n²/4 in level 1
@chetan8395
@chetan8395 4 жыл бұрын
For those who have not convinced here is the my ans c.n^2(gp of 3/16 goes k times ). So waht is k here ? K= logn base 4 there for GP becomes c.n^2((3/16)^logn + constant ) as n goes to infinity 3/16 vanished or becomes close to zero
@tauheeddarekar6509
@tauheeddarekar6509 4 жыл бұрын
k is the depth of the tree and the geometric series which we get is the end until it becomes one so we considered that it is till infinity there is a difference bro
@aditya-wh7fh
@aditya-wh7fh Жыл бұрын
Why theta tho ?
@karteek9695
@karteek9695 2 жыл бұрын
But you ignored the floor function in this question . Will the answer still be the same if you consider the floor function ? If not, what changes have to be done ? Great explanation though .
@ryanross7785
@ryanross7785 Ай бұрын
answer still same, the reason you floor it is to account for odd number n's so its a fine technical detail that gets lost in the big O notation. I wish i understood it well enough to explain but I dont so trust me, you can ignore all floor and cieling notations here.
@talhaturkumozkurt8052
@talhaturkumozkurt8052 3 жыл бұрын
"Let's assume it's not floor, just n/4" *question ends* What did we do with it
@subarnasubedi7938
@subarnasubedi7938 4 жыл бұрын
This is not a infinite sum to use the formula a/(1-r) , did you use it as infinite series considering infinity to be upper bound??
@sumitroy9737
@sumitroy9737 4 жыл бұрын
For time complexity, we always consider large input size. So n is large here. So no of terms log(n) base 3 is also large. So there are large no of terms(almost infinite for large n).
@amanshitta
@amanshitta 4 жыл бұрын
how does the depth of the tree comes into play for this particular equation??
@sams7068
@sams7068 3 жыл бұрын
THIS IS A GUESS BY A CLUELESS ALGORITHMS STUDENT: I think it was disregarded because the growth rate provided by the depth is less than the growth rate provided by the series summation. If anyone has a better answer please reply because I'm worried about my midterm coming up!
@mukul-kr
@mukul-kr 2 жыл бұрын
actually here we assumed that series is infinite but what happens really is that we go till the height of the tree. But it is very hard to solve so we assume this as an infinite gp. 😀
@TheSkyCries1
@TheSkyCries1 3 жыл бұрын
Thank you so much, this was super helpful
@GATEAppliedCourse
@GATEAppliedCourse 3 жыл бұрын
Glad it was helpful!
@behindthescene4406
@behindthescene4406 3 жыл бұрын
@@GATEAppliedCourse sir why it is theta of n^2 why not big O ?
@ahmetkarakartal9563
@ahmetkarakartal9563 2 жыл бұрын
thank you so much
@jacobhansen3871
@jacobhansen3871 2 жыл бұрын
How do you combine [n/64, n/64, n/64] into n/16^2?
@rahulnegi4618
@rahulnegi4618 2 жыл бұрын
In the recurrence relation: cn^2 is nothing but the time taken to combine the divided parts into one. Now if we look at this part where each problem was divided into n/64. When we put n = n/16 we get from the recurrence equation that each part of the n/16th sub problem is divided into (1/16)*(n/4) i.e. n/64. Further we require c*(n/64)^2 (i.e. after putting n = n/16) time to convert these n/64 sub problems into n/16 problem. hope it helps. If not reply.
@nishantbisht4296
@nishantbisht4296 2 жыл бұрын
ig it'll not be an ifintie tree becuz somwhere it will be n/2^k =1
@sarbjotarora4762
@sarbjotarora4762 3 жыл бұрын
Sir, which tool u are using to explain this video.
@Anonymous-re2jd
@Anonymous-re2jd 3 жыл бұрын
Wacom tablet
@ritabrataroychowdhury8958
@ritabrataroychowdhury8958 2 жыл бұрын
One question if we are given T(n) = 8/6T(6n/7) + 7/6T(n/7) + cn then how to draw the tree
@taadusingh7026
@taadusingh7026 2 жыл бұрын
It's been 5 months, but answering it for others... In this we exclude the time complexity due to 7/6T(n/7) as time consumed is less compared to 8/6T(6n/7). So the final answer will include the time complexity due to 8/6T(6n/7)
@Yeeezy
@Yeeezy 3 жыл бұрын
Thank you
@amanmishra-vt8hk
@amanmishra-vt8hk 4 жыл бұрын
On 4:15 We are dividing it into 3 parts but on merging of these the part we are not getting it as full...... n/4+n/4+n/4=3n/4 which is not equal to n...... Is not a problem? I am getting confusion can you plz tell me what is it?
@abcdxx1059
@abcdxx1059 4 жыл бұрын
same
@Kirmeins
@Kirmeins 4 жыл бұрын
Whatever an actual algorithm does which implements this recursion: the "missing" part is obiously not needed anymore for the solution. A quarter gets *removed* so to say because it is irrelevant to what the algorithm is doing. The sum of the subproblems must not be equal to n. The equation tells you, what value T(n) is going to have if you insert n into function T (T(n) is a notation for: Function T applied on value n). Think of it like any other function f: X->Y with f(x) = y. x is not nessecarily equal to y, but the function f applied on x is exactly y!
@EduAnmoldeep
@EduAnmoldeep 3 жыл бұрын
What is the name of this thing, by which you draw and screen share, record and all stuff???
@MadaraUchiha-sq9uq
@MadaraUchiha-sq9uq 3 жыл бұрын
Ink2Go
@Fahodinho
@Fahodinho 3 жыл бұрын
8:22 what's the point of the depth
@vinayaksharma-ys3ip
@vinayaksharma-ys3ip 2 жыл бұрын
💯💯💯👍
@ayrtontv6025
@ayrtontv6025 2 жыл бұрын
16^2 doesn't equal 64. I think you mean 4^3
@GOODBOY-vt1cf
@GOODBOY-vt1cf 2 жыл бұрын
12:20
@nickadams2361
@nickadams2361 3 жыл бұрын
this problem is straight from introduction to algorithms edition three page 89.
@GATEAppliedCourse
@GATEAppliedCourse 3 жыл бұрын
Yes, it is. This course is based heavily on Introduction to Algorithms by CLRS as we mentioned at the at the very beginning of this course.
@arminkrahbar
@arminkrahbar 2 жыл бұрын
You forgot to multiply it with the height log4n. so the answer should be O(n^2 log4n). Am I wrong?
@badsanta7356
@badsanta7356 Жыл бұрын
Yes you're wrong. He added the terms at each level manually into a series so there's no point in multiplying with log4(n). For example if you have to add 1,2,3,4 ; after doing 1+2+3+4, you don't need to multiply it with the number of terms.
@bagoferaserss
@bagoferaserss 3 жыл бұрын
why is it 9cn^2/16^2 instead of 9cn^2/64 ??
@bagoferaserss
@bagoferaserss 3 жыл бұрын
nevermind LOL
@toanpham4110
@toanpham4110 2 жыл бұрын
@divyanshudwivedi8452
@divyanshudwivedi8452 3 жыл бұрын
But series is not infinite😕 how can we use 1/1-r
@ayseberilcevik1926
@ayseberilcevik1926 2 жыл бұрын
suppose that a(n) is a geometric serial with constant "r" , we use S(n) = a(1).(1 - r^n)/(1 -r)
@mehdi-vl5nn
@mehdi-vl5nn 2 жыл бұрын
it should be t(n/4) = t(n/4*4) +c(n/4)^2 not c(n/16)^2
@krishnaprasad3350
@krishnaprasad3350 4 жыл бұрын
Why is the summation carried out till infinity when we know that it goes till log4(n)?
@Kirmeins
@Kirmeins 4 жыл бұрын
n might be infinite though, right?
@avk5277
@avk5277 3 жыл бұрын
its a convergent series.A convergent series may have an infinite number of terms but will always converge to a finite value.
@girijavarma5271
@girijavarma5271 3 жыл бұрын
why theta not big O? at end.
@ryanross7785
@ryanross7785 Ай бұрын
You can also use big O instead of theta. If something is both O(n) and theta(n) it means its an asyptotically tight bound, which is the goal when finding a bound. If its not clear what I mean, consider this: everything that is O(n) is also O(n^2) and O(n^3) and O(n^4) and everything that is asymptotically larger than O(n), but O(n) is the bound you choose because it is the closest bound to the function at hand. How do you know if your bound is the closest? It will have the same theta and big O bound (in my example, that would be O(n) and theta(n)).
@ranirathore4176
@ranirathore4176 3 жыл бұрын
one more method is akra bazii method for solving this
@saisameer780
@saisameer780 4 жыл бұрын
Your voice is like rajamouli
@el3csense
@el3csense 5 ай бұрын
My professor would only say: On this step, if you don't know what to do, go back and review your calculus I material XDDDDDDDDDDDDDDDDDDDDDD
@stupidPeopleRBored
@stupidPeopleRBored 4 жыл бұрын
how does n/4 + n/4 + n/4 = cn^2. until this is clear....nothing in the rest of this video makes any sense. i think that is where this video is failing to teach. thanks for the effort though. i have to find another resource though.
@Kirmeins
@Kirmeins 4 жыл бұрын
he never says it's equal to cn²! He says the problem of n is broken into three parts of size n/4 PLUS cn²! It's right there in the equation and he keeps saying our three-part subproblems must be *combined with* cn². If you do not listen closely enough you'll have problems with other resources as well! ;)
@sushant3209
@sushant3209 3 жыл бұрын
@@Kirmeins its very nice and respectful of you to explain him, answer him and help him clear his doubts. But your reply was a little abrasive.
@Tanque95
@Tanque95 2 жыл бұрын
cn^2 is the time that takes to 'merge' the subproblems. And that is why T(n/4) = 3T(n/16) + c(n/4)^2 takes for each 3 subproblems c(n/4)^2 times 3 ===> 3/16 * cn^2.
@bhaskarpandey8586
@bhaskarpandey8586 3 жыл бұрын
Watch at x2
@pavelbiswas3963
@pavelbiswas3963 5 жыл бұрын
I think 16 sqr = 256 not 64
@user-mq1wy8if3i
@user-mq1wy8if3i 4 жыл бұрын
Its 4^3 not 16^2
@shrey356
@shrey356 4 жыл бұрын
Shouldn't the answer be (n^2 x logn)
@rajendrakujur2078
@rajendrakujur2078 3 жыл бұрын
@Neel Rayal I think O(n²) < O(n²logn)
@ankiTKumar-cl7yt
@ankiTKumar-cl7yt 4 жыл бұрын
Sir please solve this. Problem T(n)=2T(n-1)+T(n/2)+n Using recursion tree method
@sahanasshenoy8878
@sahanasshenoy8878 4 жыл бұрын
Have you taken this question from any sources? I am wondering How can I break a problem of n into 2 problems of size (n-1) each recursivly and again n/2 ? and combine it with O(n) time??
@sahanasshenoy8878
@sahanasshenoy8878 4 жыл бұрын
imagine you have an array of size 4 and now according to your recurrence equation, it will be divided in 3,3,2 Can this be a case?
@mazenhachem146
@mazenhachem146 2 ай бұрын
IF I PASS MY FINAL TMRW IM GONNA MARRY YOU
@kells9k
@kells9k Жыл бұрын
Very good video! Helping me for studying for my midterm tomorrow tremendously. What software are you guys using to draw like that with the toolbar on the bottom? Thanks again :)
@codinggamingfun1856
@codinggamingfun1856 Жыл бұрын
same here
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 103 МЛН
No empty
00:35
Mamasoboliha
Рет қаралды 8 МЛН
Recursion Tree Method
14:04
randerson112358
Рет қаралды 150 М.
Solved Recurrence Tree Method
6:30
John Bowers
Рет қаралды 443 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 630 М.
Recursion Tree Method
32:41
Dr. Hasan Jamal
Рет қаралды 153 М.
Time complexity: Best and Worst cases | Quick Sort | Appliedcourse
15:40
GATE Applied Course
Рет қаралды 71 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,3 МЛН
Introduction to recursion trees
13:36
Professor Painter
Рет қаралды 12 М.
How To Solve Recurrence Relations
16:21
randerson112358
Рет қаралды 162 М.