Stepping Through Recursive Fibonacci Function

  Рет қаралды 197,721

Khan Academy

Khan Academy

13 жыл бұрын

Understanding why and how the recursive Fibonacci function works

Пікірлер: 245
@yanzeliu
@yanzeliu 9 жыл бұрын
This is the most clear explanation I found !! It's really nice and helpful.
@redrowolloftnod5230
@redrowolloftnod5230 6 жыл бұрын
I think it's horrible for the simple fact that it doesn't mention the stack.
@joemah555
@joemah555 5 жыл бұрын
yeah!!!!!
@jose-fi3gw
@jose-fi3gw 3 жыл бұрын
TILL THIS DAY
@manmohanchowdary1707
@manmohanchowdary1707 3 жыл бұрын
Yes bro
@dynamicdkl
@dynamicdkl 2 жыл бұрын
@@redrowolloftnod5230 after going through some recursion , i felt its working like stack . isn't it ?
@marybandziukas1544
@marybandziukas1544 4 жыл бұрын
Thank you! I have been puzzling over how this works for 2 days. Khan Academy always delivers a clear and completely understandable explanation. Mainly by use of colors and not skipping a single step.
@user-mn3iq2cs9n
@user-mn3iq2cs9n 4 жыл бұрын
This is the ONLY clear, clean, and thorough explanation of this algorithm, that I've found, on youtube or EdX. Thanks a million. You make it a good thing to shout KHAAAAAAAAAAAAAAN!!!
@max-pax
@max-pax 3 жыл бұрын
I loved it. Most productive 5 minutes of my life right after conception and birth :)
@julietonyekaoha402
@julietonyekaoha402 4 жыл бұрын
I have been going over the recursive solution of the Fibonacci sequence for a day now and I couldn't figure it out , this explanation was clear and concise and I finally understood what is happening under the hood. Thank you so much.
@Occupiedmarkus
@Occupiedmarkus Жыл бұрын
11 years later, this is still the better video than the rest
@ikroac
@ikroac Жыл бұрын
13 years after and this explanation of recursive function is still the better. Thanks a lot sir
@mr.anonymous6098
@mr.anonymous6098 2 жыл бұрын
Wow! This guy knows so much about so many things. I am truly impressed! Khan, you are a lifesaver! Watched your videos for almost every AP class that I took in High School. Now I am in college and still keep watching your videos cuz they are really helpful!
@amitdhawan579
@amitdhawan579 3 жыл бұрын
I have watched quite a few videos on recursion but this one has explained it clearest of all. Thank you very much for this awesomeness!
@alexandrafoot8783
@alexandrafoot8783 3 жыл бұрын
I went over my class notes on recursion several times and it just wasn't clicking, then 2:08 minutes into this video I suddenly get it like its as simple as 2+2. You are a skilled teacher and a gift to the world
@basedmangoes3379
@basedmangoes3379 8 жыл бұрын
Amazing explanation Sal. I have looked through many videos that explained how to trace a recursive function with two calls in one method, and this one really takes the cake.
@abdulhk79
@abdulhk79 2 ай бұрын
I did try to understand this for almost an hour. Not for this video, I really don't know how much more time was needed to figure this out. This explanation will further help me to unpack other programming aspects. Thanks a lot.
@ozzyfromspace
@ozzyfromspace 5 жыл бұрын
The mind bending thing about writing recursive code is the realization that all you’re doing is writing one function that returns a second function. The eureka moment comes when you realize that the second function could be anything, and in this case it is the starting function, perhaps with an algorithmically deprecated or advanced parameter. Then those base cases just show up to stop the code from running ‘forever’ (i.e. until your processor crashes). In a way, recursion is a way of nesting functions, and sure the values at each step have to be stored on the stack and there’s a whole bunch of clever stuff happening in the background, but essentially a recursion is when you write a program that calls itself later, in effect allowing you to build a loop of functions. I can totally see how this would be useful for generating trees and other linked data structures. Thanks for the explanation, Sal! When I was first exposed to recursive code in my freshman year, I didn’t understand it and I failed to see the relevance but now it seems more natural. Kudos to you sir, learning never stops!
@SrFrancia0
@SrFrancia0 8 ай бұрын
Very good explanation. Amazing that this video is 12 years and there isn't a newer one that explains it better
@andrewfrolov5144
@andrewfrolov5144 3 ай бұрын
Best explanation ever, even math websites couldn't get to the point what it really wants. Perfect!
@sidd8988
@sidd8988 4 жыл бұрын
I was searching for an hour to find a best explanation for a recursive function. Finally ended by here ☺️
@anilbarad1856
@anilbarad1856 2 жыл бұрын
i have seen too many videos on this but this video has best explanation ever , great video , i am going to press subscribe button...thank you.
@jra89027
@jra89027 2 жыл бұрын
This is a really good example of what is actually going on during recursion. Thank you!
@cartylove3829
@cartylove3829 4 ай бұрын
Man I wished I watched this video before doing my coding assignment, but I’m still glad I watched it because i was not able to figure it out during my assignment, and it bothered me so much afterwards. Can’t believe I never understood how Fibonacci works until now, good video 👍
@martingracchus1687
@martingracchus1687 3 жыл бұрын
amazing, for 9 years this video has been granting clarification to aspiring programmers. I am learning how to use caching and hashtables to reduce the time complexity of this function but did not fully understand how the naive solution worked and how the stack handles all of the returned values and how they are actually added. this makes so much sense now, THANKS. "The cobwebs are now removed" - artie bucco (anyone who gets this reference gets a like)
@user-zf1pl6wj4n
@user-zf1pl6wj4n 7 ай бұрын
It´s funny what you are saying, because currently the software development industry is full of "programmers" which lack of fundamentals and propper preparation.
@usraniguugl
@usraniguugl 9 жыл бұрын
Sir, THANK YOU VERY MUCH!! it's not only in knowing something but in the ability to explain it! great video!
@manish436
@manish436 2 жыл бұрын
This is very clean and clear to visualize. Our mind do not work on numbers/text, it works on visualizations/images This how we would be thing about recursion in our mind. Thanks a lot for understanding our mind & making us understand too....
@yusufgokce7524
@yusufgokce7524 3 жыл бұрын
The code up there is probably the most beautiful thing I've ever seen
@tabula.rasa.
@tabula.rasa. 4 ай бұрын
I've been struggling with this for week and this is literally the only video that cleared it up.
@zubairhasan9434
@zubairhasan9434 2 жыл бұрын
THE BEST EXPLANATION!! I've been pulling my hair off how th does this recursive call works internally. Now I've finally got it.
@KDazee
@KDazee 8 жыл бұрын
You are really a life saver sir. Your explanation was so clear I understood it in one try. Thank you
@csnick248
@csnick248 7 жыл бұрын
Actually, when solving the fibonacci problem - or more importantly recursive problems in general - we don't think in this way at all. We think about it in a pretty much mathematical way and apply the "recursive leap of faith"; that is, we assume that it works, ignore all the fuzzy details and let the computer deal with those. We only focus at one single level of computation; if we have found the base cases, have managed to break down the problem into smaller instances of the same form, solved those and combined them, then the algorithm will simply work. Perhaps you meant this. :)
@rajivnarayan5214
@rajivnarayan5214 7 жыл бұрын
Thats y you gotta program a lot. You'll realise when to and when not to use it.
@aiueo8962
@aiueo8962 Жыл бұрын
​@@csnick248i agree with you
@jmbrjmbr2397
@jmbrjmbr2397 5 ай бұрын
@@csnick248 yes but imagine this, what if they ask you the runtime of this problem? How are you going to calculate the steps this function takes? You need a deeper understanding of computer's control flow to calculate that (big O)
@itstaw
@itstaw 6 ай бұрын
Thank you lol Much clearer and more precise than other explanations I have found!
@sheldonwalkerjr8210
@sheldonwalkerjr8210 5 жыл бұрын
Thank you sooo much! I could not wrap my head around this.
@Sarah-re7cg
@Sarah-re7cg 2 жыл бұрын
This is extremely helpful. I got so caught up and confused on how to trace where in the world the interpreter is. thank you so much.
@mitchellstevens3948
@mitchellstevens3948 7 жыл бұрын
THANK YOU! I've been looking for this explanation in preparation for a tech interview, for WEEKS!
@daneeldouglass6391
@daneeldouglass6391 6 жыл бұрын
THIS IS THE MOST BEAUTIFUL EXAMPLE OF PROGRAMMING AND RECURSION!! With this example alone i have became a better programmer.
@AbhishekDubeyIT
@AbhishekDubeyIT 5 жыл бұрын
Thank you very much,I am from India, I loved the way you solved it as easy as possible. thanx again
@MegaEriable
@MegaEriable 12 жыл бұрын
SAL, YOU ROCK! I JUST CAN'T DESCRIBE HOW HELPFUL THIS VIDEO WAS TO ME! THANK YOU SO SO MUCH!
@BriteRoy
@BriteRoy 11 жыл бұрын
Omg , I was seriously baffled with recursive function's backend process since last few days and finally my doubt is (I think) clear ,basically it remembers the values in a stack and processes step by step. Now hopefully I'll be able to solve a similar recursive question.Thanks khanacademy
@CrazyTimeTraveler
@CrazyTimeTraveler 6 жыл бұрын
Thank you very much for this very clear explanation, this might save me for my test tomorrow :D
@funmathematics58
@funmathematics58 3 жыл бұрын
Best explanation of fibonacci on youtube!
@spacemeter3001
@spacemeter3001 4 жыл бұрын
Perfect video. Understood it right away. You're better than my teacher in programming. lmao
@pradeenkrishnag2368
@pradeenkrishnag2368 Жыл бұрын
Best explanation. Was trying to figure out. Now it is clear.
@astroboomboy
@astroboomboy 11 жыл бұрын
Very nice explanation of a compiler. Easy and clear!
@HJ-vk2bq
@HJ-vk2bq 3 жыл бұрын
This is the clearest explanation I have ever seen. very helpful
@ronglass5968
@ronglass5968 7 жыл бұрын
Beautifully explained. Thank you!
@HarishSm-g6s
@HarishSm-g6s 7 күн бұрын
You're just Amazing dude!!! Perfect Video to understand sum of multiple recursive functions.
@haddly123
@haddly123 7 жыл бұрын
awesome, awesome video. Have been trying to understand why fib(4) + fib(3) doesn't equal 7. You explained perfectly. Cheers
@andreaaldrich4046
@andreaaldrich4046 5 жыл бұрын
@Juan2003gtr ?
@michelberden3717
@michelberden3717 2 жыл бұрын
Exactly. This is what I also did not understand
@baabujatin
@baabujatin 4 жыл бұрын
Awesome Stuff.. Most clear as mentioned by others.. took me around 10 videos to land here... was not able to understand the concept ... Thanks Team ... Stay blessed.
@aliahmed-lj4rb
@aliahmed-lj4rb Жыл бұрын
The simplest and subtle explanation on entire youtube
@daltonistadod2855
@daltonistadod2855 Ай бұрын
I needed that so badly
@DrDerivative
@DrDerivative 2 жыл бұрын
Exactly what I needed to understand this topic, thank you!
@irfanbabar8424
@irfanbabar8424 4 ай бұрын
Simple & clear explanation. Thanks
@PratikDeshmane7006
@PratikDeshmane7006 4 жыл бұрын
Finally got the perfect explanation!
@Arif_0899
@Arif_0899 3 жыл бұрын
WoW.... I promise you once I become a software engineer, I will donate half of my first salary to khan academy and that's a promise. You really are changing lives.
@MuwalJitender
@MuwalJitender 2 жыл бұрын
Bravo Khan Academy. You are doing awesome work.
@TimmyGoesForTrip
@TimmyGoesForTrip 4 жыл бұрын
gosh that was the best to video to understand the sequence! thank you from 2020)
@felipelima2724
@felipelima2724 4 жыл бұрын
Very good explanation!!! The best!
@AdnanRizvan
@AdnanRizvan 9 жыл бұрын
Very helpful indeed.You explain a lot better than professor and it really helped me figure out how does this actually work. +1
@martinmoragab
@martinmoragab 2 жыл бұрын
Amazing explanation! Easy to understand it this way. Thanks!
@AnaGuerra03
@AnaGuerra03 2 жыл бұрын
THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU
@baryosef6245
@baryosef6245 7 жыл бұрын
Amazing explanation. You are awesome!
@ammgnero
@ammgnero 3 жыл бұрын
Holy Moly wonderful explanation sir
@ngxbeans
@ngxbeans 11 жыл бұрын
Usually rely on Khan's videos for math help. Now I have his help with CPU SCI. Very happy right now lol
@gurkiratsingh9788
@gurkiratsingh9788 5 жыл бұрын
is it legal to write fibonacci(3) with fibonacci(4) coz the fibonacci(4) will be called first before evaluating the parameter of ffibonacci(3)
@zenlupe
@zenlupe 8 жыл бұрын
Great explanation!
@wildfyah
@wildfyah 5 жыл бұрын
And just like that my headache went away. Thanks.
@yadatis5905
@yadatis5905 5 жыл бұрын
Thank you so much ☺️ sir. It's very helpful for me.
@affanzama8280
@affanzama8280 4 ай бұрын
should that not return fin(2) as 2 ? because 2
@avichiii
@avichiii 11 ай бұрын
one of the most clear explanation.
@hansnery
@hansnery 3 жыл бұрын
Thank you, I finally understood how it works now.
@trippyvoyager9879
@trippyvoyager9879 3 жыл бұрын
This is the best video i found on the internet
@markkillion6845
@markkillion6845 Жыл бұрын
Thank you for this clear explanation. It was very helpful!
@vishnu364
@vishnu364 3 жыл бұрын
simple and neat explanation...thanks a ton!!
@saicharancherry3266
@saicharancherry3266 7 жыл бұрын
is first left tree **fibonacci(n-1) or right tree **fibonacci(n-2) or both at a time are construced.......?
@himanshusaxena8639
@himanshusaxena8639 Жыл бұрын
This video would have saved my week if I found it earlier .
@lesegomabe2679
@lesegomabe2679 8 жыл бұрын
Great explanation! Thank you!
@cedricmendoza8316
@cedricmendoza8316 2 жыл бұрын
Always quality content. Thank you.
@yogi915.
@yogi915. 7 жыл бұрын
So thankful for your explanation!
@abdallahelnashar1520
@abdallahelnashar1520 Жыл бұрын
Wooooow Thank you very much Greatest Explanation Ever!!!
@zacloebs
@zacloebs Жыл бұрын
First video that made me actually understand :)
@Nasimkhadv1996
@Nasimkhadv1996 11 ай бұрын
Thank you so much for your clear explanation. This helped me a lot🤩
@FromTheV
@FromTheV 4 ай бұрын
Absolutely perfect! Thank you
@ansekao4516
@ansekao4516 2 жыл бұрын
WOW, thank you very much, bc I wasn't sure I was assuming it correctly. Thank you very much for making it clear. ;3
@andregomes7232
@andregomes7232 Жыл бұрын
Thank you so much man! you made it looks easy
@zeeshan1019
@zeeshan1019 9 ай бұрын
Lovely sir
@cellmaker1
@cellmaker1 2 жыл бұрын
This is extremely helpful. Thanks
@crakintosh
@crakintosh 13 жыл бұрын
Thnk u sal for starting cs tuts.. But i hav one question,how does the computer understand english language
@codaacademy5888
@codaacademy5888 7 ай бұрын
this is the best explanation , really thanks
@92501le386
@92501le386 3 жыл бұрын
thank you very clear explanation you have a gift, man what a talent you have thank you for taking the time to do this, its helping so many out there i do believe.
@himashihettegedona9484
@himashihettegedona9484 4 жыл бұрын
Thank you so much for this video!
@lestra378
@lestra378 2 жыл бұрын
Thank you for this amazing explanation
@voltron909
@voltron909 11 жыл бұрын
Compilers are used to interpret computer language (english word commands) into machine language (binary language such as 010101). Machine language are what processors use to carry out what you want. A compiler takes some function, and converts it to machine language.
@christanprice5720
@christanprice5720 Жыл бұрын
This was extremely helpful!
@yagnapatel3912
@yagnapatel3912 3 жыл бұрын
Everything makes sense now, much thanks
@anyavailablehandle
@anyavailablehandle 2 жыл бұрын
Great explanation !!! Thanks
@min_808
@min_808 9 ай бұрын
I think it was helpful to know that the Fibonacci sequence is computed by looking at the previous two numbers and adding them. This recursive statement works by subtracting each number from the one before, and two before and adding them together. Tracing the steps was very useful though
@hassan-rakib
@hassan-rakib 2 жыл бұрын
Genius! Saved my day!!
@gate_one_loyal
@gate_one_loyal 6 жыл бұрын
very nice explanation , thanks man
@ars7070
@ars7070 5 жыл бұрын
TQ soooooo much... Uve help me ony exam day
@pascal3719
@pascal3719 3 жыл бұрын
Greetings everyone, Please does anyone know any textbook that has practice problems on Fibonacci sequence, mathematical Induction and recursive?
@elarabymohammed1
@elarabymohammed1 8 жыл бұрын
May god bless you Sir!
@dynamicdkl
@dynamicdkl 2 жыл бұрын
there will be so many return values , how are we getting perticular value . please explain
@ravipatel-xu5qi
@ravipatel-xu5qi 3 жыл бұрын
Thank you for your efforts.
@rambodehydrated
@rambodehydrated 7 жыл бұрын
Thanks, well explained :)!
Exercise - Write a Sorting Function
2:12
Khan Academy
Рет қаралды 62 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 15 МЛН
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 12 МЛН
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 102 МЛН
The magic of Fibonacci numbers | Arthur Benjamin | TED
6:25
Fibonacci Series In Java With Recursion - Full Tutorial (FAST Algorithm)
15:11
Fibonacci Sequence
13:19
Number Sense 101
Рет қаралды 340 М.
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 111 М.
Python Lists
11:41
Khan Academy
Рет қаралды 415 М.
Recursion for Beginners - Fibonacci Numbers
10:16
NeetCode
Рет қаралды 21 М.
What on Earth is Recursion? - Computerphile
9:40
Computerphile
Рет қаралды 740 М.
Best Javascript Recursion Explanation on YouTube
10:38
DevSage
Рет қаралды 142 М.
Towers of Hanoi: A Complete Recursive Visualization
21:13
Reducible
Рет қаралды 446 М.
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 15 МЛН