Posts

Showing posts with the label Program to maintain an AVL tree.

Program to maintain an AVL tree.

#include #include #include #define FALSE 0 #define TRUE 1 struct AVLNode { int data ; int balfact ; struct AVLNode *left ; struct AVLNode *right ; } ; struct AVLNode * buildtree ( struct AVLNode *, int, int * ) ; struct AVLNode * deldata ( struct AVLNode *, int, int * ) ; struct AVLNode * del ( struct AVLNode *, struct AVLNode *, int * ) ; struct AVLNode * balright ( struct AVLNode *, int * ) ; struct AVLNode * balleft ( struct AVLNode *, int * ) ; void display ( struct AVLNode * ) ; void deltree ( struct AVLNode * ) ; void main( ) { struct AVLNode *avl = NULL ; int h ; clrscr( ) ; avl = buildtree ( avl, 20, &h ) ; avl = buildtree ( avl, 6, &h ) ; avl = buildtree ( avl, 29, &h ) ; avl = buildtree ( avl, 5, &h ) ; avl = buildtree ( avl, 12, &h ) ; avl = buildtree ( avl, 25, &h ) ; avl = buildtree ( avl, 32, &h ) ; avl = buildtree ( avl, 10, &h ) ; avl = buildtree ( avl, 15, &h ) ; avl = buildtree ( avl, 27, &h ) ; avl = buildtree...