Recursion (Think Like a Programmer)

  Рет қаралды 157,612

V. Anton Spraul

V. Anton Spraul

Күн бұрын

Пікірлер: 177
@vantonspraul
@vantonspraul 7 жыл бұрын
If you liked this video, be sure to check out my other videos about recursion: Divide and Conquer: kzbin.info/www/bejne/Z2K5aHyhZa51frc Dynamic Programming: kzbin.info/www/bejne/n6fCqnugotCpaqs The Peg Puzzle: kzbin.info/www/bejne/j5mVqoiqhbV7qqc
@ahmedsohail9855
@ahmedsohail9855 6 жыл бұрын
hey provide your book free for people like me as have no proper sources
@techsavvy1457
@techsavvy1457 6 жыл бұрын
Youth Inititiative It is for free.
@abhilashajha8822
@abhilashajha8822 5 жыл бұрын
I have been your fan ever since I read your book. It was such a great beginning for someone trying to learn to programme on her own.
@vantonspraul
@vantonspraul Жыл бұрын
Thanks for the kind words. Glad you liked it!
@ShrestaBS
@ShrestaBS 6 жыл бұрын
Finally someone who can teach recurrence without Fibonacci!! Good video 👍
@xxMpEGxx
@xxMpEGxx 5 жыл бұрын
Amen xD
@cswaale4498
@cswaale4498 4 жыл бұрын
Yess bro
@rameshreddibathuni
@rameshreddibathuni 3 жыл бұрын
Exactly!!
@ranjeet5806
@ranjeet5806 3 жыл бұрын
hahaha
@kamleshkumarsahu4699
@kamleshkumarsahu4699 3 жыл бұрын
🤣🤣🤣best
@azngiant
@azngiant 3 жыл бұрын
OMG, I was watching other recursion videos and still didn't get it until I saw yours. I thought the moment you replaced the dispatcher method to call itself without changing anything was magical! Biggest epiphany I ever experienced. You just got yourself a subscriber. I'll be watching your other videos. THANK YOU!
@vantonspraul
@vantonspraul 3 жыл бұрын
Hey, that's great to hear! This idea has really helped a lot of my students, although I think it is most appreciated by those who, like you, were frustrated by other explanations first.
@vantonspraul
@vantonspraul 11 жыл бұрын
Thanks, Alek. I agree, problem solving is often the missing ingredient when programming is taught.
@yoshuadiaz514
@yoshuadiaz514 3 жыл бұрын
Your video it`s amazing, I tried to understand recursion before without results, but, with your approach, I gain confidence and I tried with the Fibonacci and Factorial problems by myself with your approach (and without other guides) and I solved by myself without consulting stack overflow ! Thanks a lot! I bought your book! You are the man (and Batman in the night for sure)!!! Cheers from México!
@vantonspraul
@vantonspraul 3 жыл бұрын
Wow! Thank you so much! You sound like you are heading in the right direction for sure. There's nothing like the feeling a solving a programming problem on your own.
@igniteyourdesire
@igniteyourdesire Ай бұрын
I wish i had your videos 11 years ago. I would have learned programming so much better. Thank you. I was told in college after I asked how you know what to do with problems. They told me you either understand it, or you dont, and since I didn't, I gave up.
@vantonspraul
@vantonspraul 11 жыл бұрын
I didn't mean to suggest that recursion should be forced on any situation where it doesn't fit. I just meant that when learning this particular technique of recursive problem solving, I would start with applying it to situations you already can solve with iteration.
@mainaofficial8398
@mainaofficial8398 6 жыл бұрын
Nice thx sir
@mamdouhwaleed9514
@mamdouhwaleed9514 5 жыл бұрын
I really wish I had found this earlier, I have already been struggling with Recursion for a while, thanks for making this whole series, my life is way easier now
@solstice9339
@solstice9339 3 жыл бұрын
Im in literal shock right now. I'm trying your method out any recursive problem I can think of and it keeps working. It feels like this is too good to be true..
@johnneiberger7311
@johnneiberger7311 3 жыл бұрын
I'm so glad I found this video. I tried to learn clojure a couple of years ago and have been trying to learn Erlang off and on this past year. In both cases, I struggle with how to think recursively. It's so foreign to me that my brain kind of locks up with any recursive problem more complicated than factorials or fibonacci sequences. I even watched a video on dynamic programming, and while the examples made perfect sense in hindsight, I never would have come up with those approaches on my own.
@tg8iq954
@tg8iq954 5 ай бұрын
I have been stuck on the topic of recursion for several days, and now it has finally clicked.
@黎銘-s9n
@黎銘-s9n 5 жыл бұрын
This explanation of recursion is something like the bullet of a sniper that hits the target as expected. All the secret is trust, trust the result of recursive call. It reminds me of learning swimming. People can have confidence in the coach and people around that they are 100% safe in the pool. The actual steps of watching several problems solved successfully both in looping and recursion build the confidence. It's also something like building a skyscraper from the top, which is truly terrifying.
@vantonspraul
@vantonspraul 5 жыл бұрын
Those are good analogies.
@NeelSandellISAWESOME
@NeelSandellISAWESOME 4 жыл бұрын
The way I think of recursion is that I have a very long rectangle. Everytime I make a function call I am taking a small bite out of that rectangle. I eventually get to my base case and return a certain value.
@thesuperiorman8342
@thesuperiorman8342 5 жыл бұрын
I'm so glad I clicked on this video. I understood the concept of recursion but I struggled to write it in code. Your approach of converting an iterative solution to a recursive one gave me the key to unlock this otherwise difficult problem. Thank you so much.
@parasarora5869
@parasarora5869 5 жыл бұрын
finally i get to know the big idea and baby steps to take while learning recursion. all thanks to you sir. 😄
@parasarora5869
@parasarora5869 5 жыл бұрын
sir...i just now solved my first ever recursive problem by myself. i am so happy. i solved the maxVal problem without even looking at your solution. i am so thankful to you. ♥
@chenzoe8
@chenzoe8 6 жыл бұрын
Totally fall in love with the book. Thanks so much. I am now even able to write recursion function on the binary search tree. Before reading the book, I can hardly understand the factor function.
@vantonspraul
@vantonspraul 6 жыл бұрын
That's great! Glad my book was so helpful. Recursion can be pretty fun to play with once you get the hang of it.
@varun9836
@varun9836 6 жыл бұрын
True. I am getting this feeling after going through your tutorial. Thanks.
@Towhid-ze3rw
@Towhid-ze3rw 2 ай бұрын
Sir, thanks a lot for this. If I am cracking that interview, much credit will be given to you.
@YOUTUBE_IS_WOKE
@YOUTUBE_IS_WOKE 3 жыл бұрын
@8:35 , you don't need to call totalDiffDispatcher you can directly call totalDiff function and it will return the total difference. The function totalDiffDispatcher in this iterative call is redundant and should be removed. How do you write a code to solve and count the number of nodes in a treenode? Not return one single value, but show the total nodes for each sub-branches. This is easily done with forEach in C#, but in recursion it's a bit challenging, but interesting.
@hosamhasan6871
@hosamhasan6871 8 жыл бұрын
simply , you are the best . because you are the only one that explains me Recursion and i understand it directly . or may be i am stupid :)
@vantonspraul
@vantonspraul 8 жыл бұрын
Thanks, glad I could help. Believe me, lots of smart people are thrown off by recursion. It's a very different way of thinking.
@tommyeagen3763
@tommyeagen3763 3 жыл бұрын
I love your book man amazing I comeback to it often when i feel like I am losing the ability to solve problems especially the first 2 chapters and the chapter that relates most to the problem i’m struggling with
@vantonspraul
@vantonspraul 3 жыл бұрын
Thanks! I'm glad it's continuing to help.
@thejesse247
@thejesse247 2 жыл бұрын
Just found your channel. Thank you for putting amazing teaching content online for free, I would have killed for teachers like you in college.
@manamsetty2664
@manamsetty2664 2 жыл бұрын
Please don't
@davidjames1684
@davidjames1684 3 жыл бұрын
Recursion has its place in programming, but doesn't define who a programmer is. Recursion can be replaced by iteration, and self stack management (or equivalent), so it is not required. In some cases, relying on recursion will not work, as some programming environments have greatly limited stack space/capabilities. The default setting of this may need to be increased to make a "deeply" recursive program run without a stack error.
@enzoyasuo9264
@enzoyasuo9264 3 жыл бұрын
Thanks! Recursion really is a difficult topic but this helped me with some difficulties, but now I got to test them out
@Towhid-ze3rw
@Towhid-ze3rw Ай бұрын
I can't apply the dispatcher function logic for the problem statement "Remove duplicates in a string". Someone please help.
@abdenourbacha4782
@abdenourbacha4782 4 жыл бұрын
thank you very much sir ,only god knows how much i have struggled with reccursion before this video.
@vantonspraul
@vantonspraul 4 жыл бұрын
Glad to help!
@richikghosh5207
@richikghosh5207 4 жыл бұрын
one liner: base case; return totalDiffDispatcher(SensorA,SensorB,size-1)+abs(SensorA[size-1]+SensorB[size-1]);
@richikghosh5207
@richikghosh5207 4 жыл бұрын
Btw good video.
@DavidKing-wk1ws
@DavidKing-wk1ws 3 жыл бұрын
OK thats it I will buy the book but I need it hand written in no.2 pencil, reflecting 2 forms of ID, 4 major credit cards and a note from the publishers mother with proof she signed it. :)
@ruchisharma8105
@ruchisharma8105 2 жыл бұрын
Best recursion video so far.
@rawanfouda2291
@rawanfouda2291 5 жыл бұрын
Good technique! we somehow always use it but you've put it into words so that we can embrace it. Thank you!
@MultiSteveB
@MultiSteveB 9 жыл бұрын
Nice video. I had dabbled in recursion before, and wrote a PHP program to read an XML file into a ragged array.
@barelylate
@barelylate 3 жыл бұрын
Step 3 blew my mind. So cool. Thank you for this video sir
@xinfinity4756
@xinfinity4756 2 жыл бұрын
what is an example of a problem that iteration can't solve or can't solve easily that recursion can solve or can solve easily?
@mariusandries4103
@mariusandries4103 6 жыл бұрын
This is quite nice explanation on recursive function. Thanks Sir.
@vantonspraul
@vantonspraul 6 жыл бұрын
You're welcome. I'm glad it was helpful!
@mohitrai7896
@mohitrai7896 6 жыл бұрын
this playlist will also help you in recursion kzbin.info/aero/PLawezQIZQjjtlQALUagYLQI2Q1Yq1h4OC
@biccsdev
@biccsdev 5 жыл бұрын
Thanks to you, i understand recursive algorithms now... THANKS!!!!
@varun9836
@varun9836 6 жыл бұрын
This is cool. One can clearly understand recursion following your video and your book. Thanks.
@muneebzubair5069
@muneebzubair5069 6 жыл бұрын
This is not working for my problem: find any pair in array whose sum is equal to a key. bool pairSum(int key, int arr[], int s, int e) { for (int i = s; i < e; i++) { for (int j = i + 1; j
@carroviejo80
@carroviejo80 9 жыл бұрын
Kudos man, thank you very much. Im an spanish student and this is just what i need.
@11am
@11am 4 жыл бұрын
When is Think Like A Programmer, Python Edition : A Beginner's Guide to Programming and Problem Solving going to be available?
@Akshaykumar-bl8ok
@Akshaykumar-bl8ok 4 жыл бұрын
That's the good way to think , whenever recursion comes into your mind.
@mamo987
@mamo987 3 жыл бұрын
followed along and finally had something click! thank you !!
@petrnovota8238
@petrnovota8238 6 жыл бұрын
Thank you for this amazing video. Finally I am able to handle recursive problems. Well done Thank you!
@vantonspraul
@vantonspraul 6 жыл бұрын
Thanks! Glad it helped you out.
@baburao1668
@baburao1668 4 жыл бұрын
hey man, does it way to do recursion a = [1, 10, 15, 16, 12] b = [2, 10, 14, 15, 11] r = [] t = 0 def A(): for i in range(len(a)): r.append(a[i] - b[i]) B() def B(): for q in range(len(r)): if r[q] < 0: r[q] = r[q] * (-1) C() def C(): global t for e in range(len(r)): t = t + r[e] print(t) A()
@mog2182
@mog2182 4 жыл бұрын
What an awesome approach.
@vantonspraul
@vantonspraul 4 жыл бұрын
Thanks! Glad you liked it.
@shubhamdeshkar1685
@shubhamdeshkar1685 5 жыл бұрын
I was stunned at the end of this video! :0
@vantonspraul
@vantonspraul 5 жыл бұрын
Stunned in a good way?
@shubhamdeshkar1685
@shubhamdeshkar1685 5 жыл бұрын
@@vantonspraul Absolutely.. This is the best explanation I have seen.
@minhazulislam4682
@minhazulislam4682 3 жыл бұрын
6:18 if you are new to C++ programming.... Meanwhile, I never wrote a line of C++. Ironically, I use python for competitive programming.
@Freeze014
@Freeze014 4 жыл бұрын
i am like 7 years late to the party... but I am trying to understand how this works and maybe typing it out helps me organize my thoughts even if there is no reply :) I added a line that output the diff at every step and was at first surprised that it didnt start with the difference of the final position (5th reading of the sensors) and added the others as it went, but instead started with the difference of the first positions. So am I correct in thinking that when a recursive function is run, it goes until it runs into the statement that breaks the recursion (in this case if size == 0; return 0;) then it rewinds what it did and combines the total value as it would have done in a for loop?
@benfrese3573
@benfrese3573 4 жыл бұрын
Don't know if this is still relevant, but in order to understand recursive functions I would suggest you look at an explanation that includes the 'Stack' - it will make things clearer about what values are returned and how the recursive function calls are handled.
@anthonyb1053
@anthonyb1053 7 жыл бұрын
although this video isn't great, the chapter of the book that this guy wrote is awesome!! Learned recursion in one night. Thank you for posting this chapter V.Anton Spraul !!!!!!!
@vantonspraul
@vantonspraul 7 жыл бұрын
Okay, I'm going to ignore the first part of that and take this 100% as a compliment :-). I'm glad the chapter was helpful!
@Raging.Geekazoid
@Raging.Geekazoid 3 жыл бұрын
If you want to understand recursion like a programmer, stop thinking about the function you're using and start thinking about the data you're analyzing or the problem you're solving. The important thing to take away from this video is the idea of looking at the whole problem from above (i.e. from the dispatcher's point of view). Getting stuck thinking about what's inside a recursive function is confusing, because then the environment outside the function (i.e. the actual problem itself) becomes a mystery. Analyzing linear data structures is exactly what you DON'T need recursion for, and doing two of them together doesn't really make the explanation any clearer. What you DO need recursion for is tree-shaped data structures and AI decision trees, because there is no iterative version of those programs. The loops would have to be nested, and in many cases there's no way to know ahead of time what the limits of the loops and the amount of nesting would be. The next step after watching this video is to learn what to do when the dispatcher function needs to call itself more than once from the same call. 😮 If you're trying to deal with tree-shaped data, you'll need to visit every node in the tree, and how are you going to do that? You have to visit the root node first, because that's the only one you have direct access to, so it's the only way to get to the inner nodes. Then you'll need to visit the children of the root, then the children of the children, and so on down to the end nodes of the tree (trees are always pictured upside down 🙄). And the easiest, simplest way to do that is to call a function to deal with each node. If you try to do it all with one call to some kind of mega-dispatcher function, you'll have to create a data structure called a "stack" (i.e. a trail of crumbs that shows you the way back home) to remember which nodes you went through to get to the current node, and now you're re-inventing the wheel. Every program already has a stack that's used for function calls. You might as well use that. And you might as well use the same function you used on the root node, because why not? You're performing more or less the same operations on each node, except for the leaf nodes, and you don't know ahead of time when you'll run into one. If you're working on an AI algorithm, you don't know ahead of time what steps the AI will have to take, and there will be multiple possibilities at each step. So the space of possible actions for the AI to take is shaped like a tree. Might as well write a function to deal with each step and have it make another call to itself when it's time to deal with the next step. That's recursion. You'll have to put some logic in the function to decide whether it's dealing with a leaf or a branch node, but that's easy. And remember: You make calls from the top down and return results from the bottom up. (1) The function's parameter list needs to contain whatever information the function needs to analyze the nodes of the tree, (2) the return value needs to contain whatever information you're trying to extract from the tree, and (3) in many cases you'll have to combine the results of the calls to a node's children before returning from that node (the parent of the children). That's all there is to it! 🙂
@mohammedalhaythami2416
@mohammedalhaythami2416 6 жыл бұрын
Please. Design progam in C++ that contains a function that takes those characters and returns a string that contains only the upper case ! etters.. use recursion
@jlee2905
@jlee2905 6 жыл бұрын
wtf... i finally understand recursion after 4 years of wasted tuition on my CS degree! :) I'm buying your book!!!
@vantonspraul
@vantonspraul 5 жыл бұрын
Thanks! Hopefully that degree wasn't a total waste!
@PhuNguyen-yf5to
@PhuNguyen-yf5to 4 жыл бұрын
The video helps me somehow! Thank you very much!! Wish you for the best luck ever!!
@AnIndianify
@AnIndianify 6 жыл бұрын
Hi Anton, I love your series and would like to buy your book, but it costs 2200 Rupees in India which is quite a lot not only for the students but also for working professionals and there is no economic editions available for your book like some others e.g. CLRS. Can you kindly ask your publisher to release an economic edition
@viveksuman9600
@viveksuman9600 Жыл бұрын
I will just write empty iterative functions and assume it solves the problem for my own satisfaction because I still can't trust recursion. lol. This video helped alot. Thanks!
@beyondsingularity628
@beyondsingularity628 5 жыл бұрын
I think you are a great programming teacher!
@okereaforkelvin
@okereaforkelvin Жыл бұрын
Still didn't get it...😒
@syedwasay3087
@syedwasay3087 5 жыл бұрын
increase the playback speed to 1.25 will make it more easier to watch :D
@azdinefx6545
@azdinefx6545 5 жыл бұрын
how can I do this whit the factorial example ?
@Ea9Le
@Ea9Le 9 жыл бұрын
Thanks for the great explanation. Looking at your sample, what exactly would be the advantage of the recursive version?
@vantonspraul
@vantonspraul 9 жыл бұрын
+Jeremy Ymerej Thanks, glad you liked it. There's no particular advantage of using recursion here. The method I use for teaching recursive problem solving works best when you start with problems that are relatively straightforward to solve using loops, but that also means they are the problems for which recursion is least beneficial. But once you get the idea you can use it on other problems where you just pretend to write the non-recursive solution first without really writing it.
@cezarzbughin3362
@cezarzbughin3362 6 жыл бұрын
I like to think of Recursive function as being a squere with codelines inside. at the end, calling it we will get a square inside a squere inside a squere and so on, but at some point it will stop, no more squares, so the smaller square will get to its end, this will cause it to break and it breaking will cause the next one to break and the next one also. the function got to its end and now everything is breaking exactly like zuma balls.
@mohitrai7896
@mohitrai7896 6 жыл бұрын
this will also help you kzbin.info/aero/PLawezQIZQjjtlQALUagYLQI2Q1Yq1h4OC
@johnkeck
@johnkeck 2 жыл бұрын
This was very helpful--thanks!
@misharuko1514
@misharuko1514 6 жыл бұрын
Amazing!!! Thank you so much!
@vantonspraul
@vantonspraul 5 жыл бұрын
You're welcome!
@provashadhikaryshoumma6795
@provashadhikaryshoumma6795 10 жыл бұрын
Your videos are great. I wish some more videos from you.
@vantonspraul
@vantonspraul 10 жыл бұрын
Thanks! I'm working on the next one...
@tomyang7788
@tomyang7788 7 жыл бұрын
where is the base case at 9:16 , will this cause an array index out of bound exception ?
@vantonspraul
@vantonspraul 7 жыл бұрын
It's the first line of totalDiffDispatcher. The base case is size == 0.
@bismeetsingh352
@bismeetsingh352 6 жыл бұрын
Unable to apply this to dynamic problem of fibonnaci numbers. You said to have last two values in dispatcher. But my array is empty from the end.
@vantonspraul
@vantonspraul 6 жыл бұрын
I have another video on dynamic programming, specifically including the Fibonacci sequence as an example: kzbin.info/www/bejne/n6fCqnugotCpaqs. Have you checked out that one yet? If you have and you still are having trouble, post again and let me know!
@bismeetsingh352
@bismeetsingh352 6 жыл бұрын
V. Anton Spraul I haven't checked that one out yet but even if we don't use DP here,we still won't be directly knowing the last two elements.
@bismeetsingh352
@bismeetsingh352 6 жыл бұрын
V. Anton Spraul probably I expected a response
@amoghkulkarni3519
@amoghkulkarni3519 5 жыл бұрын
Awesome explanation . Thank you sir.
@asaadmaher1828
@asaadmaher1828 8 жыл бұрын
but how does totalDiffDispatcher function terminate? It will keep sending 'size-1' each time it's called, or am I getting it wrong?
@vantonspraul
@vantonspraul 8 жыл бұрын
+Asaad Maher It will do that ALMOST every time it is called. The first line of the function checks if (size==0). If it is, the function returns 0, terminating at that point so that the statement with the recursive call is never executed. So, assuming size starts off >= 0, eventually the terminating condition will be reached and the recursion will start to unwind.
@asaadmaher1828
@asaadmaher1828 8 жыл бұрын
Oops! How blind I was not to see that line!! Thanks Mr. V. Anton Spraul. I'm number one follower of your videos. Please don't stop making such great series!
@vantonspraul
@vantonspraul 8 жыл бұрын
+Asaad Maher Don't worry, it happens to us all. Thanks for the encouragement. I've got a couple of other videos in progress, just been finishing up a different project first.
@asaadmaher1828
@asaadmaher1828 8 жыл бұрын
+V. Anton Spraul One more question Mr. Anton. Can you make a video about dynamic programming. I am really confusing it with recursion. Could you support the concept by one or 2 problems, and is every recursive programming problem can be solved by dynamic programming
@IDK-kv8ob
@IDK-kv8ob 3 жыл бұрын
Love these videos.
@yankumar5280
@yankumar5280 10 жыл бұрын
thanks for sharing V. Anton Spraul
@marrylo842
@marrylo842 3 жыл бұрын
Somehow it's starting make sense to me now... 😳
@animeprofiles2077
@animeprofiles2077 4 жыл бұрын
Damn it worked so well , you are a genius !!
@biancacorbu9984
@biancacorbu9984 6 жыл бұрын
where could I find the answers to the exercises in the book?
@vantonspraul
@vantonspraul 6 жыл бұрын
Hello Bianca! I don't provide an answer key to Think Like a Programmer, because the point of the book is figuring out how to solve problems, not the solutions themselves.
@TechAsif24
@TechAsif24 5 жыл бұрын
thank you before watch your video....now i am watching
@saptarshibanerjee4757
@saptarshibanerjee4757 7 жыл бұрын
def absolutevalue(list1,list2,size): if size==0: return 0 dif=abs(list1[size-1]-list2[size-1]) return absolutevalue(list1,list2,size-1)+dif print absolutevalue([12,34,56,67],[45,56,78,90],4) this iterative code in python is not working why prof?
@EmulatE42
@EmulatE42 7 жыл бұрын
it works, but you have wrong indentation for return 0
@warshon123
@warshon123 7 жыл бұрын
You're missing a semicolon after the 'return' statement and the 'dif=abs' statement.
@bismeetsingh352
@bismeetsingh352 6 жыл бұрын
Warshon python doesn't know semicolons
@BoomcoreIsLive
@BoomcoreIsLive 3 жыл бұрын
Thank you so much, I see improvement in myself :)
@vantonspraul
@vantonspraul 3 жыл бұрын
Glad to hear it!
@rahulsolankib
@rahulsolankib 6 жыл бұрын
Ohhhh let me try!
@HA-jk6yi
@HA-jk6yi 6 жыл бұрын
Great work. Thankyou
@sravanthkumarchintalacheru1359
@sravanthkumarchintalacheru1359 4 жыл бұрын
Thanks, professor!
@computersagain
@computersagain 6 жыл бұрын
Your channel is so awesome!
@mohitrai7896
@mohitrai7896 6 жыл бұрын
this channel will also help you kzbin.info/door/oEt3glB4rWSq5zEhSGhUWA
@yashashav_dk3766
@yashashav_dk3766 5 жыл бұрын
Sir, you are AMAZING! FUCKING AMAZING. Love your book with all my heart!
@vantonspraul
@vantonspraul 5 жыл бұрын
Thank you for your kind (and not particularly kruel) words!
@_withoutwax
@_withoutwax 5 жыл бұрын
Wow this is gold 💯
@e4e585
@e4e585 2 жыл бұрын
Your voice sounds like sheldon 😆
@BigOleHeals
@BigOleHeals 5 жыл бұрын
amazing. thank you so much
@vantonspraul
@vantonspraul 5 жыл бұрын
You're welcome, sir!
@carlazacarias1810
@carlazacarias1810 5 жыл бұрын
THANK YOU SOOOO MUCH!!!!!
@jacksmollen9023
@jacksmollen9023 7 жыл бұрын
Fantastic Video!
@vantonspraul
@vantonspraul 7 жыл бұрын
Thank you, sir! Glad you enjoyed it.
@anikethdeshpande8336
@anikethdeshpande8336 6 жыл бұрын
Thank you
@saptarshibanerjee4757
@saptarshibanerjee4757 7 жыл бұрын
This is throwing error in the compiler
@robotpanda6322
@robotpanda6322 5 жыл бұрын
nice i see a steam icon
@mybigbeak
@mybigbeak 8 жыл бұрын
If you already have an itterative answer why write a recursive?? this makes no sense. the secret trick is just to assume the function already works and the use it like it does.
@saeedbaig4249
@saeedbaig4249 7 жыл бұрын
"If you already have an itterative answer why write a recursive??" So u can learn how to write recursive programs, which is useful since some programs are easier to write recursively than iteratively (if u know how to program recursively, of course). Recursive code also tend 2 b shorter then iterative code.
@mauricioxv
@mauricioxv 7 жыл бұрын
Just because you have an itterative approach it doesnt mean you will have sufficient time to wait for the result. Some problems just can not be solved by itteration in practice even if you have a correct algorithm. You can calculate the cost of an itterative approach and find out that it would take million years to find the answear.
@fahadahmad9881
@fahadahmad9881 6 жыл бұрын
Recursive code tends to be more readable, shorter and thus easier to maintain. Write a depth first search algorithm in both iterative and recursive fashions. Compare the code between the two. You'll find the recursive solution is a lot easier to read and write in most cases because you don't have to explicitly manage the stack.
@udaykadam5455
@udaykadam5455 6 жыл бұрын
Just google....( Hanoi Tower problem). U will get the idea.
@monobinachattopadhyay9897
@monobinachattopadhyay9897 6 жыл бұрын
your trick is gold
@Midna81
@Midna81 4 жыл бұрын
Brilliant.
@AhmedAli-jx9ie
@AhmedAli-jx9ie 5 жыл бұрын
not all problems could be solved with iteration
@thesuperiorman8342
@thesuperiorman8342 5 жыл бұрын
That's why he said to start off with problems that can be solved through iteration. Then once the process comes naturally to you, you can apply it to problems that can only be solved recursively.
@ngaihte
@ngaihte 5 жыл бұрын
Whoa! Mind blown
@metalflames4
@metalflames4 6 жыл бұрын
I LOVE YOU!
@siddharthmittal9355
@siddharthmittal9355 7 жыл бұрын
thanks teacher
@vantonspraul
@vantonspraul 7 жыл бұрын
You're welcome...
@Anonymous-xj6ed
@Anonymous-xj6ed 5 жыл бұрын
This is fucking some sort of magic.. this always works 😲🤯
@saidianas8284
@saidianas8284 6 жыл бұрын
How can i get the pdf version of the book for free ?
@vantonspraul
@vantonspraul 6 жыл бұрын
Just follow the link in the description to No Starch's page for the book, and from there you'll see a link to download the PDF of the chapter.
@moosegoose1282
@moosegoose1282 6 жыл бұрын
wait, so if the size reaches 0 and the recursion is done, the function will return 0 and not the final result...
@Tanssive
@Tanssive 6 жыл бұрын
TrollBronze use an if condition
@screentrailers1331
@screentrailers1331 6 жыл бұрын
main content starts at kzbin.info/www/bejne/pXzRlZyjapJ6b5Ym11s
@virengadkari383
@virengadkari383 4 жыл бұрын
was fine until you started doing this in c++ im a java kinda guy
@sishubjoshi9144
@sishubjoshi9144 7 жыл бұрын
:eye_speech_bubble:
@Bellenchia
@Bellenchia 4 жыл бұрын
Bot
@vantonspraul
@vantonspraul 4 жыл бұрын
I don't understand this comment. Who is the bot? You? Me?
Dynamic Programming (Think Like a Programmer)
14:39
V. Anton Spraul
Рет қаралды 67 М.
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН
Can You Find Hulk's True Love? Real vs Fake Girlfriend Challenge | Roblox 3D
00:24
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 3 МЛН
Programming Loops vs Recursion - Computerphile
12:32
Computerphile
Рет қаралды 1,5 МЛН
Divide & Conquer (Think Like a Programmer)
15:45
V. Anton Spraul
Рет қаралды 32 М.
Puzzles & Programming Problems (Think Like a Programmer)
11:31
V. Anton Spraul
Рет қаралды 293 М.
How To Think Like A Programmer
1:00:07
Coding Tech
Рет қаралды 2,1 МЛН
This is how I recommend you learn Recursion in Javascript
24:39
Web Dev Cody
Рет қаралды 32 М.
The 6 Core Recursive Patterns for Interviewing
11:32
Byte by Byte
Рет қаралды 34 М.
What on Earth is Recursion? - Computerphile
9:40
Computerphile
Рет қаралды 748 М.
The Peg Puzzle Solved (Think Like a Programmer)
15:38
V. Anton Spraul
Рет қаралды 9 М.
Practical Big-O Notation (Think Like a Programmer)
13:00
V. Anton Spraul
Рет қаралды 6 М.
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,5 МЛН