To understand recursion, you need to first understand recursion.
@da_lime5 жыл бұрын
to understandd recursion
@dragon_warrior_5 жыл бұрын
and then you must understand recursion recursively
@jalapenohiway5 жыл бұрын
😂😂😂
@abdelrahmanabuissa91394 жыл бұрын
And to understand recursion, you need to understand recursion
@bentabot45214 жыл бұрын
Shut up your didnt help at all
@danbw88386 жыл бұрын
Thank you for this. Its harder than you would think to find a beginner recursion tutorial thats easy to understand
@puravida777006 жыл бұрын
Agreed. First video that actually made sense. Thanks!
@Ty-vp1jp7 жыл бұрын
Again, another video that sums up 3 hours of lecture into a video under 10 minutes.
@Kyemech4 жыл бұрын
fucking right
@bevern94773 жыл бұрын
Yes
@IvanIvanov-lr1gz3 жыл бұрын
*fucking useless 10 min video*
@sotam89382 жыл бұрын
@@IvanIvanov-lr1gz ? why
@karleme96794 жыл бұрын
Was puzzled by recursion until you explained that it digs down to the base case and then works back up. Thank you
@BigStuDolla914 ай бұрын
At 4:00 you explain recursion better than the ton of videos i've been watching. thanks
@JustinDAMusic Жыл бұрын
This video is definitely one of the most comprehensive explanations of recursion for beginners. I always wondered how calculations were being done if the function is repeatedly calling itself but as explained in this video the function keeps calling itself until it reaches the base case and then only are the calculations done. I love the analogy of digging a hole.
@DoYouHaveAName12 жыл бұрын
Thank you for this explanation, I like that you compared it as "we are digging ourselves deeper into a hole and then digging ourselves out of it"
@innonhara70403 жыл бұрын
Best explanation of recursion I have come across on the net.
@absolutezero99476 жыл бұрын
Amazing video, not monotonous, but still gives a good overview and lesson on recursion in python! Keep up the good work!
@oggiai6 жыл бұрын
Thanks
@nuhibrahim2152 жыл бұрын
great job! keep it up! finally, a detailed explanation of recursion explaining about the things that going around in the background...
@jarrodabott Жыл бұрын
A very concise explanation without your face as the focus but rather the issue at hand. The tutorial is on point without having to learn the creation of the universe, which is so annoying. My first Python subscription and like (whoa!).
@maximum30802 жыл бұрын
thank you so much, you probably will never see this comment or care but i personally wanted too thank you for helping me to understand recursion better, my computer science teacher was explaining it and I had a hard time understanding but when you explained simpler it it was much easier to understand :)
@oggiai2 жыл бұрын
Glad to hear that! 😀
@baharehkjani6761 Жыл бұрын
THANK YOU, DANKE, MERCI, SHUKRAN, SEPAS
@JJJJ-gl2uf2 жыл бұрын
Clearly spoken, good explanation, fairly easy to understand. Well done.
@chinmaydas40537 жыл бұрын
Sir your are doing great job.It's very helpful when you first give the pseducode of that algorithms then give the programs in specific language implementation..love you sir.please give more and algorithms implementation in java and python programming languages..this will be very helpful for us...
@mybluemars3 жыл бұрын
Thank you Joe! Now I have a basic understanding of RECURSION and can see how searches such as tree traversals and binary code work. :)
@asands1235 жыл бұрын
I get it. I GET IT.
@confidential3034 жыл бұрын
Was this a recursive answer?
@abs80905 жыл бұрын
I needed to refresh my memory on recession and your video was short and straight the point, THANKS
@BuildingImpossibleDreams4 жыл бұрын
Thank you for actually saying iterative is a loop. Book after book and video after video never say iterative is loop.
@johnjones7647 жыл бұрын
Excellent job. Your explanation is clear and easy to follow. Please do more videos like these. Many thanks for your help and hard work.
@WhetūAroha5 ай бұрын
Thanks for explaining this in a such simple and doable manner! 🎉🎉
@akira_asahi2 жыл бұрын
Thank you for the video. I am gratuful for your time and contribution. Kind regards, Akira.
@alphabetsalphabets52423 жыл бұрын
Very nice! Visualizing it like you did at 4:52 made it extremely obvious and clear. Very good tutorial and explanation.
@alphabetsalphabets52423 жыл бұрын
@Sabinka47 then you don't understand recursion.
@alphabetsalphabets52423 жыл бұрын
@Sabinka47 if you have a function calling itself it needs to be able to pass the data back to the place where it was called.
@mrsdhuha4 күн бұрын
This is very good way of explaining it - Many thanks.
@CasperWest3 жыл бұрын
THANK YOU! BEST VIDEO ON RECURSION!
@jk30894 жыл бұрын
Thank you Sir. Blessings be upon you. God bless you with peace.
@ryandoucette43432 жыл бұрын
Greatly appreciated for your time to explain these concepts.
@simonfortin29435 жыл бұрын
2019 and I appreciated the visual explanation very much! Thank you.
@gyanology33563 жыл бұрын
Thankyou sir for making this kind of helpful video for us. It really helped me to understand what recursion is.
@antonlinden52165 жыл бұрын
Came up with a short recursive python snippet while you were beginning to explain the topic. 5 lines, if anyone has a shorter one, post it below ;) def factorial(n): if n > 1: return n * factorial(n - 1) return n print(factorial(5))
@ferhatakbulut65724 жыл бұрын
def factorial(n): return 1 if n < 1 else n * factorial(n-1) print(factorial(5))
@ea15763 жыл бұрын
I promise you i love you omds this made everything so clear.
@animegirl4lyfe7 жыл бұрын
Great video! We are learning recursion right now
@impmadness3 жыл бұрын
3 years later, how has your programming knowledge advanced thus far? I’m curious, Im studying for a CE degree and I’ll learn recursion in a few weeks
@bhallalot5 жыл бұрын
Thanks for the explanation. I really appreciate how you explained the part about the memory. This cleared up my confusion. This was organized really well!
@carbon93572 жыл бұрын
You explained this amazingly
@bocarlsson3rd3 жыл бұрын
Now I get it!! Thank you very much.
@4500danny2 жыл бұрын
Great explanation in a simple way. Thanks
@גלמלאך8 ай бұрын
I think I fell in love with the word factorial
@michaeljames13343 жыл бұрын
this was a super good video. i appreciate it. subbed.
@muhammadaffaq66874 жыл бұрын
Superb Explanation. Hats-off.
@oggiai4 жыл бұрын
Thanks.
@michaelcostantino53972 жыл бұрын
Well done! Thank you. Very clear and easy to follow.
@Kyemech4 жыл бұрын
Definitely earned a subscribe here, thank you very much Joe
@Sickkkkiddddd Жыл бұрын
Watched 20 videos today and I am still dumb as a rock about recursions. I'm ready to pick up knitting or another hobby that doesn't make me question my sanity. Can't keep putting time and effort into computing concepts designed to kick my ass.
@oggiai Жыл бұрын
Start slow and easy. Learn to use variables, lists, for loops and if-else statements first. Then build on it. Recursion is a tricky concept to understand, but this is as simple as I can make it.
@anag992 жыл бұрын
The cons and pros finally gave me a good perspective on this
@shpazhist5 жыл бұрын
Hey Joe -- Really luv your videos -- can you pls do a video tho with the list what one needs to learn to become really more-or-less professional developer? I.e. Like im personally trying to learn it by myself and think that sorta Im on early-intermediate level of proficiency; however, there is not even one single good source that Ive encountered that would really expand more on actual Software Engineering/Computer Science *list of topics one need to know* rather than just Foundations/Syntax. I.e. what CS areas one MUST know like, for instance, this concept of recursion: Like the following is the list that came to my mind but perhaps you can add on from your experience: 1. recursion 2. CRUD 3. algorithms 4. MVC/MVT for Django 5. What are design patterns and why one needs to learn them 6. version control 7. Waterfall engineering model 8. Types of programming: functional, OOP, etc -- why need different? 9. Dynamic programming vs. static 10. What/Why testing is needed? 11. SCRUM/Agile etc 12. how to better learn problem solving skills for coding/approaches/methods of thinking etc, other important topics/concepts/areas .... and etc and in all fairness, someone who would do, say, 1hr/30 mins lecture with literally covering all these topics for like 30sec/1 min each per term in 1-2hr would be an absolute GOD of youtube!!!! for all software developers as he would provide a sorta oxygen to combine all CS concepts (not just syntax) into one sorta coherent and comprehensive fashion. Even just mentioning all the terms, saying, ok -- CRUD is for websites, Waterfall model is just for writing your code, OOP is for writing logical steps for organizing processes and attributes of objects etc Thus, the biggest problem for the inexperienced like me is that all these terms come just from trial and error of exploring and working on problems rather than anyone really covering them first and sorta providing a blueprint or a path on how to become an advanced software engineer I hope I explained what Im looking for but if not, please revert and I will be happy to expand. and Many thanks for your channel again!
@gobhandle2 жыл бұрын
Thank you man, this was an excellent explanation.
@heavydremer87162 жыл бұрын
thanks bro this helped alot fr. subscribed!!
@KillerTacos543 жыл бұрын
That was immensely helpful, thank you!
@NeilLTayler4 жыл бұрын
thank you man, very helpful
@RRatedT4 жыл бұрын
Great video, btw you don't really need the "else" on 05:10, because if it's not lower than 2 it doesn't go in anyway so you can just write on the same tab as the if "return ...". Thanks for sharing the video! :)
@noramarji15384 жыл бұрын
Thank god for this video
@s1mo2 жыл бұрын
before this recursion seemed impossible to me, thanks
@helovesdata84832 жыл бұрын
I wont lie, recursion wore me out, but I get it now. Often I like to loop through a directory in python with the os.listdir() function. I realize a for loop will only go through the directory but not directories within the directory.
@oggiai2 жыл бұрын
Directories are Trees, and are a perfect application for recursion.
I have a recursive function written that wants to “unwind” itself after the base call has been executed. How do stop/prevent unwinding
@ShiwenDing4 жыл бұрын
very well explained, thanks a lot for the illustration !
@mdougf4 жыл бұрын
Beautiful. Thank you sir.
@dilshangunathilaka55513 жыл бұрын
wow. Thanks a lot man ❤️❤️
@FullMetal-nu8bj6 жыл бұрын
Could someone explain on a lower level how recursion works? How does the interpreter assign each recursive call to memory? how does it keep track of the call stack?
@oggiai6 жыл бұрын
The call stack works just like it always works. Each new function call gets it's own call frame on top of the stack, and that frame stays open until it returns a value. So when you get deep into a recursive series of function calls you could have a very large call stack that eats a ton of memory. That's where the term "Stack Overflow" comes from, if you run out of memory allocated to the stack.
@polysopher6 жыл бұрын
Hi, a little late but you can try python tutor visualization. www.pythontutor.com/visualize.html#mode=display
@philb14665 жыл бұрын
@@polysopher Never too late! There's always someone looking around for information on topics that may be sometime in the past.. Like me! 😁 .. thanks, that link really helped, even a year later!
@magnacarta70452 жыл бұрын
@@polysopher 4 years later, this still helped. Thanks!!
@sschiavo81906 жыл бұрын
Simple and to the point.
@xinyichen14182 жыл бұрын
Rly helpful. Thank you!
@icontentacademy2 жыл бұрын
Excellent video. In recursion how is the fact tracking the total. I see in code how we are tracking the total using iteration, but how does it remember the total using recursion? Hope my question makes sense.
@oggiai Жыл бұрын
It’s returned from successive function calls.
@jamiewise35283 жыл бұрын
Great job! Thank you!
@seankearsley62454 жыл бұрын
thanks Joe James
@sergiobatista52654 жыл бұрын
finally understand it now. thank you.
@regivm1236 жыл бұрын
Great tutorial. On this topic I face a bottleneck and not able to explain. I tried to sum all natural numbers of 'n' and not able explain the mechanics. def sum_n(n): if n== 0: return 0 else: print('n ', n) res = n + sum_n(n-1) print('res ',res) return res print(sum_n(5)) n 5 n 4 n 3 n 2 n 1 res 1 res 3 res 6 res 10 res 15 15 As the loop run, n is reduced to 1... it is clear. However, res adds cumulatively AFTER this. I expected print(res) to print one value (15). Is there a loop between 'res = n + sum_n(n-1)' and 'return res'?? It is slightly different to your example. But can you clarify?
@TheLambPost6 жыл бұрын
It's similar to a loop but you have to visualize it differently to really understand what's happening. Each time you hit the res = n + sum_n(n-1) line the entire function is called again (going deeper down the hole as Joe said), until res == 0 (the bottom of the hole). At which point it returns 0 back up to the previous time that the function was called, which was when n = 1, so now the line res = n + sum_n(n-1) is really res = 1 + 0, and the code continues from there to return res, which is now 1, farther back up the hole. Each time res increases by a small amount until you get back to the original call to the function, and at that point you have the final answer to the algorithm. If it still doesn't make sense it might help to make a chart of all the variables and what value they have at each call to the function, then to follow the code line by line and fill in the chart as the values change.
@ibrahimal-mahfooz87375 жыл бұрын
Well explained. Thumbs up!
@shiridalal2734 жыл бұрын
now I get it. thanks!
@raibahati4 жыл бұрын
Very well explained ! Thank you Sir!
@spankfanuka93455 жыл бұрын
Perfectly explained. Thank you
@ignaciomarin69275 жыл бұрын
helpful and to the point, thanks a bunch!
@gedtoon64512 жыл бұрын
It would be interesting if you used timeit on both algorithms and see which is faster in python.
@Stellarspace955 жыл бұрын
MY BRAIN HURTS
@silas-hw92744 жыл бұрын
Same this just isn't making sense
@christophercarr58653 жыл бұрын
I think new people need to understand the call stack before they get recursive functions. You can get the structure of recursion in the abstract well enough, but not understand how it seems to magically spit out the answer when it stops recursing.
@silverfluoride50734 жыл бұрын
Splendid, I read through my lecture's book and got totally confused, now with this video I just realized the lecture's book sucks
@KoryGraphic4 жыл бұрын
I'm in the same situation, I have had a lecturer that could barely speak English and he was teaching from an unnecessarily complicated set of slides.
@zoemohamed65993 жыл бұрын
Thanks Joe
@rafaelmaranhao37102 жыл бұрын
Great video!
@denizkrom97724 жыл бұрын
thanks for the video!
@unutilizzatoreyoutubbicoca77494 жыл бұрын
amazing
@abigailspencer4113 Жыл бұрын
I wrote out the same code at the end and got different numbers. I got 6 from get_recursive_factorial and 1 for get_iterative_factorial. Not sure why the outputs would be different with the same code and inputs.
@oggiai Жыл бұрын
Share your code
@oscarschuller23092 жыл бұрын
very nice video
@augustasmaciulskas41242 жыл бұрын
Thank you, helped a lot.
@ekkomanhighlights3883 жыл бұрын
Thank you !
@albertovitess18985 жыл бұрын
Thank you. I get it ,plz can you make a video on tables ?
@oggiai5 жыл бұрын
I have several on reading in data files, and on Pandas.
@He_ze2 жыл бұрын
Wow I'm such a dummy. I didn't realize the difference between factorial and factor until now lol
@wolfcompany24 жыл бұрын
i dun get it :/ 5:16 if i say getFac(4) it will return n * (n-1) , 4 * (4-1) = 12 ? How does this work LOL? i can understand the iterative, but the recursive i died... like where is the loop for the recursive??!!? HOW DOES IT CALL ITSELF I DONT GET IT
@oggiai4 жыл бұрын
Sorry that’s as simple as I can make it. You might benefit from watching a few other Recursion videos. And if you call getFac(4) it should return 4x3x2 = 24.
@Kingofqueers16 жыл бұрын
Can you list some applications of recursion, for example where would someone use recursion in the real world
@oggiai6 жыл бұрын
Recursion is very commonly used in Tree algorithms, like doing a Find in a binary search tree. In fact, it would be tough to implement a tree without recursion.
@zeinelmokhtar41055 жыл бұрын
In the recursion way, someone will need to write down five functions - before calling them- to just calculate "5!". right?
@Ronitrocket5 жыл бұрын
no the function calls it self. You make it once, you call it once
@markwild5086 жыл бұрын
Great video man
@AliHaider-bc7cl7 ай бұрын
def fu(x): if x>0: result = x+fu(x-1) print(result) else: result = 0 return result fu(5) output: 1 3 6 10 15 could anybody please help me out with how this is working .. iv not been able to figure it out yet. thanks
@yogendrarajahsaarangan4574 жыл бұрын
what will happen to the code after recursion function called? code afterward executed every time or after the recursion function finishes ?
@yogendrarajahsaarangan4574 жыл бұрын
def m_sort(arr): if len(arr) > 1: mid = len(arr)//2 a = arr[mid:] b = arr[:mid] m_sort(a) m_sort(b) i = j = k = 0 while i < len(a) and j < len(b): if a[i] < b[j]: arr[k] = a[i] i += 1 else: arr[k] = b[j] j += 1 k += 1
@yogendrarajahsaarangan4574 жыл бұрын
in this code that while loop will be executed everytime when recursion function executed or it will be executed after the recursion function finishes ?
@oggiai4 жыл бұрын
Yogendrarajah Saarangan the recursion has to finish before the rest of the program can execute.
@yogendrarajahsaarangan4574 жыл бұрын
@@oggiai thanks
@user-tt3vp1uw6o2 жыл бұрын
I would have liked an example or two of recursive functions that would not work because they would go on forever
@charlesmuthini13936 жыл бұрын
Excellent.
@Anonymous-pr3gr6 жыл бұрын
Is it normal that my for loop can compute much larger factorial numbers than the simple recursion my prof codded?
@oggiai6 жыл бұрын
not surprising, as I mentioned, recursion's achilles heal is the risk of stack overflows for function calls.
@wexwexexort6 жыл бұрын
You should check out what "memoization" is.
@jorriffhdhtrsegg2 жыл бұрын
I now understand recursion. I now don't quite understand why 0!=1 again. 😄
@maximum30802 жыл бұрын
this is probably old but in his example it breaks it down at 4:46 and at the bottom you can see that it returns 1 so you can think in the sense that even if its 0! its still gonna end up returning 1. Idk if this helped at all and you most likely figured it out already but hope you have a good day
@nahilachowdhury17855 жыл бұрын
Lovely Vid :)
@maquindesign91585 жыл бұрын
Can recursion be explained without factorial?
@oggiai5 жыл бұрын
Yes, one of the best applications for recursion is in trees, such as a find function in a binary search tree. But it’s not easy to explain recursion using a tree example because the tree itself is a higher level concept than recursion.