I\'ve written a method to help build a quadtree. Each quadtree has a root node, and a root node has 4 children. I\'m using depth recursion to stop this function from dividin
Your handling on the recursive call to buildTreeHelper
seems perfectly correct. You check the depth
terminating condition before recursing, and you always call it with depth-1
.
The only potential prolem I can see is if it's the constructor calls (the ones creating the children) which call buildTreeHelper
again. That could result in infinite recursion if, for example, the constructor always calls buildTreeHelper
with a object variable for depth
(it would have the same or a greater value each time).