- 25,806
- 50,624
Why can't you do something like:Fun recursive vs iterative CS question:
I'm building a hex tree where each node has the address of its six neighbors if they exist ex:
I start out with one node and as I need to expand the space it occupies I keep adding nodes (and have to assign the new nodes to its neighbors if they exist!!). Once I'm done I need to deallocate the memory space of all those nodes without leaving behind any nodes or double deleting.
I'm going to write the recursive implementation for delete and would be interested to see the iterative implementation.
Note that I might give up and try a completely different and better approach once I realize how slow searching is and how much better octrees or kdtrees are for my problem.
Software engineering bonus question: Find a current implementation that does all this with better performance and reliability than I can.