How to debug complex data structure?

Baesky

Newcomer
Hi everyone,do you have experience for debuging complex data structure like quadtree,octree and so on.If you implement the algorithm how did you make sure it works fine?One of my ideal is rendering them visually, what's your opnions?
 
Don't reinvent the wheel, use existing, tested implementations. Tweak if needed and use unit tests every bit of the way.
 
Best way to make sure your implementation works is to write good unit test coverage for it (as an additional bonus, unit tests will ensure the algorithm works in the future as well, when you start to optimize it further). One easy way to test these kind of structures is to write comparison tests against a known working implementation (simple brute force linear array implementation is enough). Randomized unit testing can be quite handy, if you are not sure what are exactly the most important cases to test (and/or you are not sure you are hitting every corner case). Just feed the same random input to both your implementation and to the known working solution and compare the results.
 
Back
Top