Hello. I implemented an AVL Binary Tree with insertion based on left and right rotation (as is by default) and deletion with the same balance checking as the insertion.
I want to draw the tree in Win32 GDI and I succeded so far exept that I cant store the nodes depth level after an AVL rotation without iterating the whole tree again. I want to store nodes levels so I can draw the lines that connect each nodes at different angles for each level so the nodes wont touch.
As in picture http://s23.postimg.org/w454umihn/avl.jpg
When I draw the Tree I get every node by depth with a Queue that stores the children of a node and after that goes to the other and display the node and so on. I can store the level of the node in the Queue because I dont know when the level changes as the Queue always stores children but never knows when the level is finished. Or at least I dont know how to implement that.
Please give me a hint. Should I try storing the levels when the Queue is processed and the tree is traversed in depth or should I store the node of every level in a different traversal ?
Thanks