- UID
- 2198
注册时间2005-6-29
阅读权限255
最后登录1970-1-1
副坛主
该用户从未签到
|
.
实现了树的增加、删除、遍历等操作
这是一个通表 可以用于大多数的数据来创建索引
int main(int argc, char* argv[])
{
cout<<"This is My AvlList-Tree Code By: Nisy"<<endl<<endl;
AVLList * Tree = new AVLList();
TreeNode * & rootp = Tree->tree;
AvlNode Data(0,0);
for(unsigned int j=1;j<=5;j++)
{
for(unsigned int i=1;i<=11;i++)
{
Data.nCrcNum = i;
rootp = Tree->InsertNode(rootp,Data);
}
}
Data.nCrcNum = 4;
rootp = Tree->DeleteNode(rootp,Data);
Data.nCrcNum = 1;
rootp = Tree->DeleteNode(rootp,Data);
Tree->PreOrder(rootp);
return 0;
}
输出:
This is My AvlList-Tree Code By: Nisy
6(3) 6(L0) 6(L1) 6(L2) 6(L3)
3(1) 3(L0) 3(L1) 3(L2) 3(L3)
2(0) 2(L0) 2(L1) 2(L2) 2(L3)
5(0) 5(L0) 5(L1) 5(L2) 5(L3)
8(2) 8(L0) 8(L1) 8(L2) 8(L3)
7(0) 7(L0) 7(L1) 7(L2) 7(L3)
10(1) 10(L0) 10(L1) 10(L2) 10(L3)
9(0) 9(L0) 9(L1) 9(L2) 9(L3)
11(0) 11(L0) 11(L1) 11(L2) 11(L3)
Press any key to continue |
|