Suppose there is a 2d matrix n by n such that majority of the ints inside the matrix is 0 while the leftovers are 1s.
E.G 10 by 10, with 20 randomly placed 1s and other are all 0s.
I want to use tree recursion to find out the number and the depth of branch for all the 1s. (top/down/left/right/diagonal)
int m = 0;
m = 1
m = 1
Number of tree = 1, depth of branch = 2.
So bascially my code is in an infinite loop. Since I am using tree recursion, my code is bouncing on the same branch, take the above example for example. My code check whether m has a 1 if true then use recursion and check all the unit beside it, then it detect (0,1) have a 1 -> proceed to check all the unit beside it, and found out (0,0) is a branch -> (0,1) ->(0,0) infinite XD.