Hi here I am again, I know how recursive method works but the problem I'm facing now is analyzing this recursive method. I'm just testing the method.
The output I have is
I'm trying to analyze how did I get that output, but it seems that I'm totally lost I can only analyze the output if I only have one method calling itself once but method calling itself twice-can't discover the process. Any help would be appreciated
It hardly makes a difference even if a method calls itself n times.
Just imagine there is only 1 call. Resolve the complete stack flow of the that 1 call and get the result. Now for the second method, just add a call to each stack entry. Write it down and you ll get it, if not... please tell, I'll represent diagramatically.
I think you can have a better understanding of this code by drawing the stack that is formed by the calls to the checkGrid method. In each item in the stack, write the arrayLength passed to the method. Put some sysouts in the code to help you in this simulation.
SCJP 1.4 - SCJP 1.6 - SCWCD in progress
Joined: May 26, 2009
I minimized the problem.
Here's the calling I created. I don't know if this is correct or not, if it's correct then the problem I have is understanding the things that the function will return to be able to see the output. I guess I'm kinda near to the light of understanding the recursion-1 function calling itself twice.