Its always that one Indian person that explains it better than your learning materials and the teacher combined
@alessandrocamillo49396 жыл бұрын
You’ve been the first and the best to clearly explain the math behind fast Fibonacci matrix computation .
@gkcs6 жыл бұрын
Thanks!
@ITACHIUCHIHA-dr8sz Жыл бұрын
6 years later, and still the best video explaining this on youtube!
@gkcs3 ай бұрын
Thank you!
@shreyasahu4817 жыл бұрын
when the yellow tee turns blue magically! nice video though :)
@gkcs7 жыл бұрын
Haha :-P Thanks Shreya!
@abhaypatil20005 жыл бұрын
also he wore spectacles
@shreyaghosh29568 ай бұрын
Wow! Thank you for making it so simple to understand. This was the clearest explanation of matrix exponentiation.
@manishankar15936 жыл бұрын
I loved the Maths involved into this problem, fascinated!
@iprakhar227 жыл бұрын
Appreciate your work a lot, Man! Something I like about you is that you choose your words very carefully before speaking just so that every kind of audience can understand you.
@gkcs7 жыл бұрын
Thanks Prakhar!
@vidhansharma17876 жыл бұрын
Thanks bhai.... People like you help guys ,those are not from good colleges in ind.. to improve their competitive programming skills......
@Speak4Yourself25 жыл бұрын
Not even the best of colleges in India teach any Competitive Programming.
@Speak4Yourself25 жыл бұрын
@ 'coDiNG cULtUre' starts from You. When you code, (and code well, with time and practice) your friends/juniors are inspired to follow in your footsteps. Over the years this inspiration spreads as a ripple effect batch after batch. Then the college calls itself as having good 'coDiNG cULtUre'.
@subhodip52935 жыл бұрын
Great Teaching. Your energy is very engaging to the viewer and your explanations are clear and intuitive.
@theIcemanYT5 жыл бұрын
the channel I should have found a year ago. Awesome explanation.
@gkcs5 жыл бұрын
Thanks! 😁
@atulsaswat11534 жыл бұрын
At 17:45, when we do the final multiplication, we should consider f(1) = 1 and f(0) = 0 giving us f(14) = 377 & f(13) = 233. That doesn't defeat the purpose of the understanding though. Your explanations have a good buildup and that is probably why it's so appealing.
@rishavsaha52543 жыл бұрын
Yes, you are correct but in the beginning of this video, he assumed both f(1) and f(0) equal to 1.
@ashishchourasia2830 Жыл бұрын
The best explanation for this on the internet
@andermerketegi11772 жыл бұрын
It really helped me understand how to apply Matrix Exponentiation for my particular problem. Great video, thanks!
@FeroChau6 жыл бұрын
This is amazing! It's so satisfying to watch this.
@tanishq27662 жыл бұрын
The way your eyes shined, when you said THE MATRIX ! NEO FOREVER
@akhilesh592 жыл бұрын
Best Explanation so far with reason behind each and every step! Loved it... Thank you Sir.. ♥
@saranshdabas42237 жыл бұрын
Learning a lot from your videos, they are unlike any other sources available for competitive programming...
@gkcs7 жыл бұрын
Thanks Saransh!
@NiceBot7246 жыл бұрын
This video needs a lot more likes than just hundreds
@gkcs6 жыл бұрын
I agree 😉
@abhishekkarn89187 жыл бұрын
I can add one thing here if anyone is stuck until what power do we have to calculate the powers: just do: 2^(floor(ln(n)) and you will get the required number. For n=13, you will get 2^3, which is 8. Hope it proved to be of some help. And Thanks a Lot Gaurav for such a brilliant video. You are literally one of the best. :)
@gkcs7 жыл бұрын
Thanks Abhishek :-)
@adoq3 ай бұрын
i was just looking for a way to find fibonacci numbers quickly with pen and paper, i didnt get my answer but i got valuable dynamic programming knowledge lol. works either way
@gkcs3 ай бұрын
Excellent!
@Rajat_maurya Жыл бұрын
6 years later also helping many of us
@viditmathur84376 жыл бұрын
your explanations are awesome , I really like the mathematical explanations . This video really helped me understand the log(n) approach to find fibonacci sequence which i couldn't understand from texts :D.
@gkcs6 жыл бұрын
Thanks Vidit!
@LuisaGrigorescu4 жыл бұрын
Great explanation! You made math much easier to understand. All the explanations from the internet are to mathematical and imply having prior knowledge to all these terms and formulaes.
@dugong3695 жыл бұрын
For those who aren't aware, storing the lower powers isn't needed (see wikipedia article on Exponentiation by Squaring for example). Following a sequence of squaring and multiplication determined by the binary bits of the exponent eliminates the need to store those intermediate results. It's probably better that you explained it the way you did though because that avoids a complication which isn't relevant to the main point, O(log n).
@Manojshankaraj7 жыл бұрын
Great video Gaurav! Please keep posting such wonderful videos. Thanks a lot!
@udaysaiphanindra31384 жыл бұрын
what an explanation sir, MIND BLOCK
@ZMacZ2 жыл бұрын
Less coffee or more meditation, enhances calm during explanation.
@abhimanyubahree14555 жыл бұрын
Wow solid explaination!!! Very easy to understand
@securityintech4 жыл бұрын
at 4:20 I don't understand why do we require f(n-1) in the matrix, if the conditions are satisfied, we got [1 1] and f(1) and f(0), both of them are 1x2 and 2x1 matrix, resulting will be 1x1.
@aayush_dutt6 жыл бұрын
Elegantly explained bro! Thanks a lot
@gkcs6 жыл бұрын
Thanks!
@amoghdesai91385 жыл бұрын
Should have this channel earlier. Very concise and useful explanation :)
@sohanursohan24264 жыл бұрын
It's helpful.Good work brother. From Bangladesh ❤
@MegaAkash1234567 жыл бұрын
Great tutorial! matrix exponentiation is very useful in solving such linear recurrences in dp problems.
@gkcs7 жыл бұрын
Thanks Akash!
@themusicalmonk27323 жыл бұрын
You are Simply Genius.. man..
@fenil8612 жыл бұрын
Thanks for this video. It helped me in gaining good insights for the approach to this problem.
@khudkikhoz3 жыл бұрын
Exactly this depth all we need... tx brother
@parth73003 ай бұрын
Goat explanation 🐐🐐
@Chesstreamer5 жыл бұрын
Just scrolling through your videos and bazzinga, found this fibonacci video,i have once used the code without understanding it somewhere on codechef but now i have understand it thoroughly,very simple and lucid exlplanation of yours helped me a lot.can u do some more problems on dp like state reduction and those involving trees tha would be of great help
@beonthego87252 жыл бұрын
Bless you Gaurav. Thank you
@vijaypratap3564 жыл бұрын
bro i am frustated from data structure and algorithm but there is some which does not let it go.when i will see ur videos they encourages me to learn but i dont know what exactly to learn for understanding complex problems of ds and algo.how do you solve the problems in minutes thats really amazing.
@shaswatdas65534 жыл бұрын
17:45 "Both of them will be 1 and 1"
@uarangat4 жыл бұрын
Wonderful teaching brother, keep it up. Helped a lot. Many thanks.
@xiquandong11836 жыл бұрын
Very good explanation. Thanks !!
@gkcs6 жыл бұрын
Thanks!
@purvampujari6 жыл бұрын
Thanks bro , helped me solve medium level ( broken clock ) problem of this feb18 long !
@gkcs6 жыл бұрын
+Purvam Pujari Awesome!
@travelinGuitarist6 жыл бұрын
lol
@jayshree90375 жыл бұрын
Any topic become interesting when it's you 😁 also those spects give me granny vibes😄🤫 Thanks😍
@gkcs5 жыл бұрын
😂😉
@sivasainagireddi79562 жыл бұрын
such a great explination !!!! thanks broo
@siddhantsharma71074 жыл бұрын
You've explained it wonderfully. Wow!
@sumit-kushwah9 ай бұрын
Thank you Gaurav 💌
@beautifultime90314 жыл бұрын
Very well explained. Thanks for sharing.
@Snehaa22963 жыл бұрын
very cool intro GKCS!
@ManishKumar-kw7qeАй бұрын
Great explanation
@kiransfitnesstips409510 ай бұрын
Nice explanation bro...
@rethink20s5 жыл бұрын
Great teaching skill bro...
@RapartiChaitanya4 жыл бұрын
Loved this explanation!
@sunnysam696 жыл бұрын
Amazing bro. Very nicely explained. Have been struggling to calculate fibonacci term efficiently.
@gkcs6 жыл бұрын
Glad it helped :-)
@nazrulhassan63103 жыл бұрын
great explanation brother
@shaziasamreen85844 жыл бұрын
Very good explanation
@BluEx223293 жыл бұрын
Sequences of threes? Wow that's the holy trinity. My mind is blown and im agnostic
@TravellerMann6 жыл бұрын
Good efforts bro..keep it up
@gkcs6 жыл бұрын
Thanks!
@AmanSharma-hi3fd5 жыл бұрын
12:04 The Matrix XD , you are the chosen one.
@sarcaastech4 жыл бұрын
Great video .. I saw some other video on the same topic but it was not engaging like this one ... ✌️🔥
@91vasanth4 жыл бұрын
Wonderful explanation Gaurav. That smile at 18:19 haha ! And I have one doubt from that point. How did you say that to raise to the power we just took log(n) time? and you also said something about the number of bits to represent that number. Could you please explain me this? I was so satisfied with the understanding until I arrived at this point ! :(
@gkcs4 жыл бұрын
Hey Vasanth, thanks for the feedback 😁 This link will help explain the logn bits: qr.ae/TWyJOx
@ravirayal75902 жыл бұрын
amazing and very informative video, thanks
@souryasaha40017 жыл бұрын
Nice Explanation. Keep up the good work.
@gkcs7 жыл бұрын
Thanks Sourya!
@angshumanbhowmik10204 жыл бұрын
Amazing video sir👍
@srijanpaul3 жыл бұрын
I remember this from the book SICP! It was an exercise in the first chapter iirc. I saw the solution on community scheme wiki and was very impressed by this way of thinking about the problem.
@omshree9012 жыл бұрын
What is the full form of SICP?
@the_dark_kerm2 жыл бұрын
Really great explanation
@gkcs2 жыл бұрын
Thank you 😁
@prathameshautade26793 жыл бұрын
Amazing explanation dude:)
@tarunpatel81685 жыл бұрын
that an awesome explanation, thankyou for the video
@ronaldvonk5 жыл бұрын
Very nice explanation and nice correction :-). The only thing is: even though this way of calculation may seem efficient; the total sum wil rise exponential and will be difficult to hold in memory; even for low values of N!
@gkcs5 жыл бұрын
Yes that's true, although most of the questions around this have us taking a remainder of the result. So ans % m turns out to be small enough to fit in memory :)
@ronaldvonk5 жыл бұрын
But you will store every 2^N th step of the Fibonacci sequence in memory, right Gaurav Sen? The 2^3=8th step is only [[34,21],[21,[13]] , but the 2^5=32th step is already [[3.524.578, 2.178.309],[2.178.309, 1.346.269]] and rising exponential; resulting is a lot of digits. Which step will you take the modulo m and with what purpose?
@ronaldvonk5 жыл бұрын
But you certainly gave me an idea for storing these exponential rising values as (mod 2^k) :-D. This may do the trick. Is that what you meant?
@gkcs5 жыл бұрын
@@ronaldvonk yup 😁
@ronaldvonk5 жыл бұрын
Like: the actual stored values in the matrices too?
@9871aa3 жыл бұрын
If you set F(0) = 0, like wikipedia says, you could have even a simpler algorithm: raise matrix to the n-th power and get the 1-st row, 1-st column element.
@gkcs3 жыл бұрын
Good idea 👍
@rajatparab81165 жыл бұрын
Awesome explanation Keep up this great work Thanks a lot broo👍
@manthankhorwal14774 жыл бұрын
Why can't we use implementation of pow function to modify it to directly calculate for matrix same as we do it for a number ?
@arreankit7 жыл бұрын
Thanks, Gaurav !! Nice Explanation.
@gkcs7 жыл бұрын
Thanks Ankit!
@kautukraj4 жыл бұрын
Very helpful!
@joshua_dlimaАй бұрын
Enjoyed it, thank you!
@gkcsАй бұрын
Cheers!
@vanshgupta24 Жыл бұрын
the curious thing about fibonacci is that every fibonacci is golden ratio times bigger than the previous fibonacci , like 8 and 5 are in the ratio of 1.6 or 8 is golden ratio times bigger than 5. early numbers dont show it but eventually the pairs starts to converge to golden ratio, so for any large n the fibonacci is phi raised to some expnonent of n (check yourself). so you can just return pow(phi,n)*base , base here is any suitable fibonacci number that has significantly converged, and n is new shifted target .
@gkcs Жыл бұрын
You won't get the exact number using this, but you will get an approximation.
@KaranDoshicool4 жыл бұрын
very well explained
@wedonotgogymnow2 жыл бұрын
How to multiply those 2 matrices [1 1] x [f(n-1) f(n-2]?
@tanvirahmed-vu2xy4 жыл бұрын
In which order i will multiply the matrix?? If i take the reverse order is it correct??
@ankitmishra-dp9tx4 жыл бұрын
Thanks alot for this video. Immensely helpful and love your passion while explaining the problem. Newly created fan :D
@zaid6527 Жыл бұрын
thanks, very well explaned
@mansinawani89705 жыл бұрын
Thanks for this amazing video...
@monideepde74137 жыл бұрын
Very nicely explained. Thank you
@gkcs7 жыл бұрын
+Monideep De Thanks!
@rahulsaxena50155 жыл бұрын
How do we find the matrix to be "exponentiated" in different questions?
@umangbehl81522 жыл бұрын
good explanation
@Pro35125 жыл бұрын
Why it is showing class not found exception when i ran the code in github in online IDE for JAVA ?
@gkcs5 жыл бұрын
Lmgtfy.
@misudey32817 жыл бұрын
Nice Video And good explanation :) liked it a lot :)
@gkcs7 жыл бұрын
Thanks Misu :-)
@ktxh4 жыл бұрын
hi, shouldn't matrix^0 be an identity matrix?
@khalilshaik61615 жыл бұрын
thanks dude!
@letsghoomo Жыл бұрын
good job Sir
@longvu20334 жыл бұрын
very nice explanation =))
@neosapien2474 жыл бұрын
Damn, I wish I had teachers like this in college.
@sivanipentapati55387 жыл бұрын
can u post the link of code??
@harshsrivastava52556 жыл бұрын
FIBOSUM on spoj..
@amankumarkashyap4006 жыл бұрын
How can matrix multiplication be O(1) ?? let's assume that we are multiplying two n*n matrices ,than the time complexity will be O(n^3).
@gkcs6 жыл бұрын
If the size is a constant, it can be assumed to be constant. N cube for 3 is a constant: 27 :)
@chalapathinagavarmabhupath84324 жыл бұрын
Yeah thank you 😊😊.
@priyabratamallick76296 жыл бұрын
Hey Gaurav , It is a wonderful explanation, but I found a small flaw in the explanation. i.e. f(14) is 377 not 610 and f(13) is 233 not 377. We are getting it wrongly beacuse you have considered f(0)=1 which is actually 0. Anyway thanks of your nice work dude.
@gkcs6 жыл бұрын
Thanks Priyabrata!
@karthikrockrr2 жыл бұрын
Mind blown !
@mandavasairaghavendradines65824 жыл бұрын
Hey, great explanation. Nowadays you are doing more of system design stuff. I think once a while you can also post more these kind of videos