Program for AVL Tree in C

Here you will get program for AVL tree in C.

An AVL (Adelson-Velskii and Landis) tree is a height balance tree. These trees are binary search trees in which the height of two siblings are not permitted to differ by more than one. i.e. [Height of the left subtree – Height of right subtree] <= 1.

A C program is given below which performs various operations like creation, insertion, deletion and printing for an AVL tree.

Program for AVL Tree in C

 

Output

1)Create:
2)Insert:
3)Delete:
4)Print:
5)Quit:

Enter Your Choice:1

Enter no. of elements:4

Enter tree data:7 12 4 9

1)Create:
2)Insert:
3)Delete:
4)Print:
5)Quit:

Enter Your Choice:4

Preorder sequence:
7(Bf=-1)4(Bf=0)12(Bf=1)9(Bf=0)

Inorder sequence:
4(Bf=0)7(Bf=-1)9(Bf=0)12(Bf=1)

1)Create:
2)Insert:
3)Delete:
4)Print:
5)Quit:

Enter Your Choice:3

Enter a data:7

1)Create:
2)Insert:
3)Delete:
4)Print:
5)Quit:

Enter Your Choice:4

Preorder sequence:
9(Bf=0)4(Bf=0)12(Bf=0)

Inorder sequence:
4(Bf=0)9(Bf=0)12(Bf=0)

1)Create:
2)Insert:
3)Delete:
4)Print:
5)Quit:

Enter Your Choice:5

Category: DSA

6 thoughts on “Program for AVL Tree in C

  1. Ayman

    Hey.. I wan to write an iterative C function that displays the integer values of a given AVL tree ..if somebody can help would be perfect ?

    Reply
  2. Mann Parutthi

    Not working properly
    if i select create node and enter 5 elements 1 to 5 in order then it is giving the wrong values of BF for each node

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *