C#的Project_Demo AVL树 [英] Project_Demo AVL Tree by C#
本文介绍了C#的Project_Demo AVL树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当AVL树不平衡时,我不知道如何说明将树变为平衡的过程.如何管理树中键的坐标?你能帮助我吗?谢谢!
标记为作业[/EDIT]
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!
Tagged as Homework [/EDIT]
推荐答案
我认为您可以使用GDI + API绘制直线和圆.
我可以建议一种获得这种树的图形表示的方法,这很有意义:
-对于节点的横坐标,请使用节点等级(从0到NumberOfNodes-1)或节点键(假设数值从Key [0]到key [NumberOfNodes-1]);
-对于纵坐标,请使用深度信息(在根处为0,在每个级别上增加1个单位).
显然,您将不得不缩放这些值,以使其恰好适合绘图窗口.坐标的线性变换即可. (在网上查找Windows/Viewport教程.)
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.)
这篇关于C#的Project_Demo AVL树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文