#include <stdio.h>
void avlInsert(treePointer *parent, element x, int *unbalanced){
if (!*parent){
*unbalanced = TRUE;
*parent = (treePointer)malloc(sizeof(treeNode));
(*parent)->leftChild = (*parent)->rightChild=NULL;
(*parent)->bf=0; (*parent)->data=x;
}
else if(x.key < (*parent)->data.key){
avlInsert(&(*parent)->leftChild, x, unbalanced);
if(*unbalanced)
/* left branch has grown higher*/
switch((*parent)->bf){
case -1: (*parent)->bj= ㄱ;
*unbalanced=FALSE; break;
case 0: (*parent)->bf= ㄴ; break;
case 1: leftRotation(parent, unbalanced);
}
}
...하략...
} /*end of avlInsert*/
To embed this project on your website, copy the following code and paste it into your website's HTML: