Did not understand the bottom up approach

did not understand the bottom up approach

hello @Aditya-Kushwaha-914550392281281
see the recurrence relation for this problem is

ways(n)= ways(n-1)+ways(n-1)+ ways(n-2) … ways(n-k) ( this u might be knowing from top down appoach).

so in bottom up we are applying the same logic .
suppose we want to compute ways to reach i .
then what we do , we simply take sum of last k entries.
ie
ways[i]=ways[i-1]+ways[i-2]+ways[i-3]+ways[i-4] … ways[i-k].

and because in bottom we compute ways to reach each i from (1 to n) ,we put this in for loop.
ie
for(int i=1;i<=n;i++){
ways[i]=ways[i-1]+ways[i-2]+ways[i-3]+ways[i-4] … ways[i-k]. // handle cases where index become negative
}

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.