mardi 24 février 2015

Data structures: how do I draw recursion trees?



I have a question which I'm not sure how to begin. Can someone explain how to do this recursion tree? And is there anyway to do it on Java?


For the recursive method fnc(n,k) defined below, draw the recursion tree of the call fnc(3,5).



Your diagram should include the return values for all calls to method fnc(n,k). public static int fnc(int n, int k) { if ( (n <= 1) || (k <= 1) ) { return n+k; } else { return fnc(n-1,k) + fnc(n,k-2); } }





Aucun commentaire:

Enregistrer un commentaire