Professional Documents
Culture Documents
h"
#include "conio.h"
struct Node {
int data;
int height;
Node *pLeft;
Node *pRight;
};
struct AVL {
Node *pRoot;
};
p->pRight = temp->pLeft;
temp->pLeft = p;
return temp;
}
p->pLeft = temp->pRight;
temp->pRight = p;
return temp;
p = pNew;
return;
}
if (p->data == x) return;
else if (p->data > x) {
Them(p->pLeft, x);
} else Them(p->pRight, x);
}
else { //lech phai
p = XoayTrai(p);
}
}
void main()
{
AVL t;
KhoiTao(t);
Them(t.pRoot, 3);
Them(t.pRoot, 4);
Them(t.pRoot, 5);
NLR(t.pRoot);
_getch();
}