Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when unbalanced AVL tree, I do not know how to illustrate the process of turning trees into balance. How can I manage the coordinates of the keys in the tree? can you help me? Thank you!

[EDIT] Tagged as Homework [/EDIT]
Posted
Updated 27-Apr-12 22:31pm
v2
Comments
OriginalGriff 28-Apr-12 3:25am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Sandeep Mewara 28-Apr-12 4:29am    
Comment from OP:
I am executing the operation illustrated AVL tree, I use C # to implement but do not have to carry the idea, the idea is you can help me. For example, after performing the operations add, delete, balanced finish, I proceeded to draw trees, how can I do?
OriginalGriff 28-Apr-12 4:36am    
Edit your question and give us better info: look at the question above, and think about it from our side: that is all the information we have. We do not have your code, we don't have you homework instructions, we don't have your data.
If you do not give us the information we need to look at your problem, we can't help!
Help us to help you - give us relevant code fragments, give us an example of what you are trying to achieve!
(Oh, and don't post comments as answers - use "reply" instead - that way we get appropriate emails!)

1 solution

I assume you are able to use the GDI+ API for drawing lines and circles.

I can suggest a way to obtain a graphical representation of such trees that makes sense:

- for the abscissas of the nodes, use either the node rank (from 0 to NumberOfNodes-1), or the node key (assuming numerical values, from Key[0] to key[NumberOfNodes-1]);

- for the ordinates, use the depth information (0 at the root, increasing by 1 unit at each level).

Obviously, you will have to scale those values so that they nicely fit in the drawing window. Linear transforms of the coordinates will do. (Lookup Windows/Viewport tutorials on the Web.)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900