本课程设计通过详细讲解和实践操作,教授如何判断及调整二叉树的不平衡状态,帮助学生掌握二叉树平衡算法的核心原理与应用技巧。
```c
#include
#include
#include
#include
int main(){
BSTree T, t, p;
int e, s;
Bool taller, lower;
void Print();
void About();
InitAVL(T);
InitAVL(t);
InitAVL(p);
system(title 平衡二叉树操作演示);
Print();
scanf(%d,&s);
while(s != 8){
switch(s) {
case 1: // 显示
printf(\t>>-显示-<<\n);
printf(T:\n);
ViewTree(T,5);
printf(t:\n);
ViewTree(t,5);
break;
case 2: // 查找
printf(\t>>-查找-<<\n);
printf(\t选择树(1,2):);
scanf(%d,&s);
if(s == 1) s = SearchAVL(T,e);
else if (s == 2) s = SearchAVL(t,e);
if(!s)
printf(\t查找失败\n\t);
break;
case 3: // 插入
printf(\t>>-插入-<<\n);
printf(\t选择树(1-T,2-t):);
scanf(%d,&s);
}
}
}
```