How recursion stack works

my i/p is n=4,k=3.

f(-2,3) <- this will return 0;
f(1,3) <- whats the ans of rest of the steps ?
f(3,3)
f(4,3)

hello anyone herer ?

first you put f(n) in the stack,
Bhaiya has taught this thing in an intuitive/graphic way.
let me explain this in a technical way.

push f(n) to the stack
repeat until !stack.empty()
f(i) = stack.top();
stack.pop();
if arrived at base case:
    add it to the ans
else:
    push f(i-1)...f(i-k) in the stack

f(4) = f(3) + f(2) + f(1)
f(3) = f(2) + f(1) + f(0)
f(2) = f(1) + f(0) + f(-1)
f(1) = 1
f(0) = 1

what is wrong in this ?
f(-2,3) <- this will return 0;
f(1,3) <- whats the ans of rest of the steps ?
f(3,3)
f(4,3)

can you explain with the stack i have made

Where is f(2,3)?..

n=4,k=3
f(-2,3) <- -----------> (4-3,3)
f(1,3) <- -----------> (4-2,3)
f(3,3) -----------> (4-1,3)
f(4,3)
there is no place for f(2,3) ? why should we include that ?

I really can’t understand what you are trying to say here.
4-1 = 3 ok that’s fine
but then you do 4-2 = 1 ?

f(-2,3)
f(1,3)
f(3,3)
f(4,3)

NOW TELL ME WHAT RETURNS WHAT VALUE ?

f(1,3) would add f(1-1,3) , f(1-2,3) , f(1-3,3) to the stack.
f(0,3) would return 1;
the other two would return zero.

f(1,3) would add f(1-1,3) , f(1-2,3) , f(1-3,3) to the stack. how ?
i dont understand this line

just to make sure we are on the same page, can you please tell me the recurrence relation of the problem.

i am skipping this problem i dont want to do this anymore thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.