Thank you so much for adding the captions, I have trouble processing spoken words sometimes and it goes in one ear and out the other, being able to read and hear the words at the same time helps it stay in my brain. You're a lifesaver and this is an excellent explanation.
import time # Memoization # initializing array with size atleast n+1 of fib you want to calculate list1= [0]*51 def fib_memo(n): #Checking if value is present or not in List if list1[n]==0: # Base Case if n
First of all, thanks for the video. I have a doubt. Is "underscore" allowed in the beginning of a function name. What does this "underscore" at the beginning of function name mean ?
int fib(int number, int *dp){ if(number < 2) return number; if(dp[number] != -1 ) return dp[number]; dp[number] = fib(number-1, dp) + fib(number-2,dp); return dp[number]; } dp is an array the max number this function can count there fib number is 46 if you want to count bigger number you must change the data type int to long long int
if memoization is also done with help of recursion then why its time complexity drastically reduces ?? ......is it related to the storing of data......please explain
u computed fib(n-1) while not considering fib(n-2) at the same time...wont those two parts be computed paralely?! can anyone explain?is it because the compiler executes a statement from left to right? is there any proof or reasoning?
Dm me on discord, I'll send you the chart, how fib function recursively call the next fib function, untill we heat the baseCase.. Because i can't post the chart here :(
Recursion is not the problem here . without memoisation we were running and calculating the same code again which was causing unnecessary calls and computation so complexity increased With memoisation we are storing the calculated values and we are not running the repeated code as we have already run that and stored the result This saves us from unnecessary calling of functions and reduces the time required to execute the code (time complexity)
Thank you so much for adding the captions, I have trouble processing spoken words sometimes and it goes in one ear and out the other, being able to read and hear the words at the same time helps it stay in my brain. You're a lifesaver and this is an excellent explanation.
Thank you GFG! Dynamic Programming was never easy to understand before this.
Thanks Reeti Garg for the appreciation!
you just nailed it in just such a small video ..... totally rocked 1k thanks to you .....
keep helping us....
Excellent, thanks for putting this together.
Greatly explained sir...love u sir
import time
# Memoization
# initializing array
with size atleast n+1 of fib you want to calculate
list1= [0]*51
def fib_memo(n):
#Checking if value is present or not in List
if list1[n]==0:
# Base Case
if n
How we calculate time complexity in DP??
Thank you very much!
Thank you @geeksforgeeks
Sephiri! Thanks a lot! Cheers!
This guy is the goat
Sir,I think here we need to use NULL instead of NIL
First of all, thanks for the video. I have a doubt. Is "underscore" allowed in the beginning of a function name. What does this "underscore" at the beginning of function name mean ?
Nothing. It's exactly the same.
Idk about other programming languages but in dart we use to to declare private class
Bro isn't mamoization a bottom up approach ?
int fib(int number, int *dp){
if(number < 2)
return number;
if(dp[number] != -1 )
return dp[number];
dp[number] = fib(number-1, dp) + fib(number-2,dp);
return dp[number];
}
dp is an array the max number this function can count there fib number is 46 if you want to count bigger number you must change the data type int to long long int
if memoization is also done with help of recursion then why its time complexity drastically reduces ?? ......is it related to the storing of data......please explain
I have a doubt why n is used to return answer I don't think we are storing any values in n
after 46 it is not giving the right answer which datatype should i use??
suraj chawla long would work
even long long isn't working after 70 i guess
How come fibonacci using iteration solves this problem in o(n) without dynamic programming?
How can i use this in lis problem ?
u computed fib(n-1) while not considering fib(n-2) at the same time...wont those two parts be computed paralely?! can anyone explain?is it because the compiler executes a statement from left to right? is there any proof or reasoning?
Dm me on discord, I'll send you the chart, how fib function recursively call the next fib function, untill we heat the baseCase..
Because i can't post the chart here :(
even in memoisation we are performing the recursion then how the time complexity decreses
Recursion is not the problem here . without memoisation we were running and calculating the same code again which was causing unnecessary calls and computation so complexity increased
With memoisation we are storing the calculated values and we are not running the repeated code as we have already run that and stored the result
This saves us from unnecessary calling of functions and reduces the time required to execute the code (time complexity)
Audio is very low
low volume
public class recurssion {
public int arr[] = new int[8];
public int fib_recurrive(int n)
{
if (n
#include
using namespace std;
#define MAX 100
# define NIL -1
int lookup[MAX];
void initialize()
{
for(int i=0;it;
while(t--)
{
int a;
cin>>a;
cout
not all heroes wear capes
what is base condition
fibonacci of zero is zero and fibonacci of one is one are the base conditions
aww explanation sir :)
AWESOME !!!!
i can't hear shiii
102334155--done
Print kaise kre!!
Return value ko kaise store kare
#include
#define NIL -1
#define MAX 100
int look[MAX];
void initial()
{
int i=0;
for(i=0;i
Add this line to your main function:
initial();
thanks.....