Posted 20 September 2013 - 12:16 AM
Another thing to concider is to make automated tests. When you write the tests make then simple but be sure to cover common occurences. For a quadtree, make a test for when the object being added intersects multiple quadrants. Make a test that overflows a quadrant so it has to be split. Making automated test helps you think of corner cases to thouroghly test your algorithm in small parts so you can have more confidence it works as a whole.
I don't know of any easy answers. But a few things come to mind. First, find a scenerio where you can duplicate the bug evertime. The fewer steps the better. Then drill down with a debugger viewing intermediate values and making sure they match expected output. Also, having some way to visualize the quadtree is usefull, drawing it out to the screen for example.