Friday, 6 November 2015

Total No. of Questions—8] [Total No. of Printed Pages—4 Se at No. [4657]-573 S.E. (Computer Engineering) (I Semester) EXAMINATION, 2014 DIGITAL ELECTRONICS AND LOGIC DESIGN (2012 PATTERN) Time : Two Hours Maximum Marks : 50 N.B. :— (i) Attempt Q. No. 1 or Q. No. 2, Q. No. 3 or Q. No. 4, Q. No. 5 or Q. No. 6 and Q. No. 7 or Q. No. 8. (ii) Figures to the right indicate full marks. (iii) Assume suitable data, if necessary. 1. (a) Do the following conversions : [6] (i) (101110.0101)2 ( )10 (ii) (432A)16 ( )2 (iii) (428.10)10 ( )2 P.T.O. [4657]-573 2 (b) Reduce the following using K-map techniques : [4] f(A, B, C, D) = (0, 2, 3, 8, 9, 12, 13, 15). (c) What is logic family ? Give the classification of logic family. [2] Or 2. (a) Minimize the following expression using Quine-McClusky : [6] f(A, B, C, D) = m (0, 2, 3, 6, 7, 8, 10, 12, 13). (b) Explain with neat diagram two input CMOS NAND gate. [6] 3. (a) Explain Look Ahead Carry generator in detail. [6] (b) Explain with neat diagram working of serial- n serial-out 4-bit shift register. Draw necessary timing diagram. [6] Or 4. (a) Explain rules for BCD addition with suitable example and design one digit BCD adder using IC 7483. [6] (b) Design given sequence generator using J-K FF. Sequence is 1 3 5 6 7 1 [6] [4657]-573 3 P.T.O. 5. (a) Draw the ASM chart for the following state machine. A 2-bit up counter is to be designed with output QAQB, and enable signal ‘X’. If X = 0, then counter changes the state as 00 —01 — 10— 11 — 00. If ‘X’ = 1, then counter should remain in current state. Design the circuit using JK-FF and suitable MUX. [7] (b) Write VHDL code for 4-bit adder using structural modeling style. [6] Or 6. (a) Write a VHDL code for 8 : 1 MUX using Behavioural modeling. [7] (b) Draw an ASM chart, state diagram and state table for synchronous circuit having the following description. The circuit has control input C, clock and outputs x, y, and z. (i) If C = 1, on every clock rising edge the code on output x, y and z changes from 000 — 010 —100 — 110 — 000 and repeats. [4657]-573 4 (ii) If C = 0, the circuit holds the present state. [6] 7. (a) Draw and explain Basic architecture of FPGA in detail. [6] (b) Implement the following functions using PLA : [7] f1(A, B, C) = m(0, 3, 4, 7) f2(A, B, C) = m(1, 2, 5, 7). Or 8. (a) A combinational circuit is defined by the functions : f1(A, B, C) = m(3, 5, 7) f2(A, B, C) = m(4, 5, 7). Implement the circuit with PLA having 3 input and 3 product term with 2 output. [7] (b) Implement 4 : 1 MUX using PAL. [6]

Wednesday, 7 October 2015

shortest path

#include<stdio.h>
#include<conio.h>
#define MAX 1000



void dijkstra(int n,int v,int cost[10][10],int dist[10]);

int main()
{
 int n,v,i,j,cost[10][10],dist[10];
 clrscr();
 printf("\n Enter the number of Nodes: ");
 scanf("%d",&n);
 printf("\n Enter the Weight Matrix:\n");
 printf("\nEnter 1000 to denote Infinity\n");
 for(i=0;i<n;i++)
 {
   for(j=0;j<n;j++)
   {
     scanf("%d",&cost[i][j]);
   }
 }
 printf("\n Enter the Source Node:");
 scanf("%d",&v);
 dijkstra(n,v-1,cost,dist);
 printf("\n   Shortest Path from Node : %d",v);
 printf("\n#################################\n\n");
 for(i=0;i<n;i++)
 {
    printf("Distance to Node: %d is %d\n",i+1,dist[i]);
 }
 return 0;
}

void dijkstra(int n,int v,int cost[10][10],int dist[10])
{
  int i,u,count,w,flag[10],min;

  for(i=0;i<n;i++)
  {
    flag[i]=0;
    dist[i]=cost[v][i];
  }
  count=1;
  while(count<n)
  {
    min=MAX;
    for(w=0;w<n;w++)
    {
       if(dist[w]<min && !flag[w])
       {
    min=dist[w];
    u=w;
       }
    }
    flag[u]=1;
    count++;
    for(w=0;w<n;w++)
    {
       if((dist[u]+cost[u][w]<dist[w])&&!flag[w])
       {
   dist[w]=dist[u]+cost[u][w];
       }
    }
 }

}

news paper using kruskal alog

#include<iostream.h>
#include<stdio.h>
int parent[10]; //initial value 0 due to global initialization

class kruskal
{
 int a,b,u,v,i,j,n,noofedges;
 int visited[10],min,mincost,cost[10][10];
public:
 kruskal()
{
 noofedges=1;
 mincost=0;
}
 void read();
 void kruskals(int cost[][10],int n);

};
void kruskal::read()
{
 cout<<"Enter the no. of vertices";
 cin>>n;
 cout<<"Enter the adjacency matrices";
 for(i=1;i<=n;i++)
 for(j=1;j<=n;j++)
 {
 cin>>cost[i][j];
 if(cost[i][j]==0)
 cost[i][j]=999;
 }
 kruskals(cost,n);
}

void kruskal::kruskals(int cost[][10],int n)
{
 cout<<"The minimum cost edges are \n";
 while(noofedges<n)
 {
 min=999;
 for(i=1;i<=n;i++)
 for(j=1;j<=n;j++)
 if(cost[i][j]<min)
 {
 min=cost[i][j];
 a=u=i;
 b=v=j;
 }
 while(parent[u])
 u=parent[u];
 while(parent[v])
 v=parent[v];
 if(u!=v)
 {
 noofedges++;
 cout<<"\n Edge ( "<<a<<"->"<<b<<")"<<min;
 mincost+=min;
 parent[v]=u;
 }
 cost[a][b]=cost[b][a]=999;
 }
 cout<<"\n \n Minimum cost \t"<<mincost<<" ";

}
  main()

java program for queue

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Graphics;
public class queue extends Applet implements ActionListener {
 TextField t1, t2;
 Button b1, b2, b3, b4;
 TextArea T;
 static int n;
 int i, front=0, rear=0, item, count=0;
 String s1, s2;
 int queue[];
 public void init() {
 t1 = new TextField(10);
 add(t1);
 t1.setText("");
 Button b4 =  new Button("queue Limit");
 add(b4);
 b4.addActionListener(this);
 t2 = new TextField(10);
 add(t2);
 t2.setText("");
 Button b1 =  new Button("Push");
 add(b1);
 b1.addActionListener(this);
 Button b2 = new Button("Pop");
 add(b2);
 b2.addActionListener(this);
 Button b3 = new Button("Display");
 add(b3);
 b3.addActionListener(this);
 T = new TextArea(20, 30);
 add(T);
 }

 public void actionPerformed(ActionEvent e){

 Button source = (Button)e.getSource();
 if(source.getLabel() == "queue Limit"){
 try {
 s1 = t1.getText();
      n = Integer.parseInt(s1);
    queue = new int[n];
    }  
   catch(Exception e1) {
    System.out.println(e1.getMessage());
    }
 }
       if(source.getLabel() == "Push"){
 try {
    if(count < n) {
 s2 = t2.getText();
     item = Integer.parseInt(s2);
     queue[rear]=item;
 t2.setText("");
      rear++;
     count++;
     }
    else{
 T.setText("");
     T.setText("queue IS FULL\n");
 t2.setText("");
 }
    }
   catch(Exception e1) {
    System.out.println(e1.getMessage());
    }
   }
 if (source.getLabel() == "Pop") {
 if(count!=0) {
 T.setText("");
     T.setText("The item deleted is: "+queue[front]+"\n");
     front++;
     count--;
     }
    else{
 T.setText("");
     T.setText("queue IS EMPTY\n");
 }
   if(rear==n)
    rear=0;
 }
 if (source.getLabel() == "Display") {
 int m=0;
 T.setText("");
    if(count==0) {
 T.setText("");
    T.setText("queue IS EMPTY\n");
 }
    else {
    for(i=front;m<count;i++,m++)
    T.append(" "+queue[i]);
    }
   }
 }
}

dictionary

#include<iostream.h>
#include<conio.h>
#include<string.h>
struct dict
{
 char key[20];
 char mean[20];

};

void main()
{
int n,i,f=0;
char k[20];


clrscr();
cout<<"\t\t\t\tDictionary Dpcoe\n\n\n\n" ;

//insert operation

struct dict d[30];
cout<<"how many key u want to enter\n";
cin>>n;
//insret
for(i=1;i<=n;i++)
{
 cout<<"enter key:\t";
 cin>>d[i].key;
 cout<<"enter meaning\t" ;
 cin>>d[i].mean;
}
 //diplay

cout<<"key      \t      mean \n" ;
//display
for(i=1;i<=n;i++)
{
cout<<d[i].key<<"\t";
cout<<d[i].mean<<"\n";

}


cout<<"enetr key to serch\n" ;
cin>>k;
// logic for search oprration

for(i=1;i<=n;i++)
{
if(strcmp(d[i].key,k)==0)
{
cout<<"meaninig is \t";
cout<<d[i].mean;
f=1;

}
}

if(f==0)
{  cout<<"update key\n" ;
}

//update

cout<<"enetr key to be updated\n" ;
cin>>k;
for(i=1;i<=n;i++)
{
if(strcmp(d[i].key,k)==0)
{
cout<<"meaninig to be updated \t";
cin>>d[i].mean;
}
}

//diply updated:

cout<<"updated dictionary is\n" ;

for(i=1;i<=n;i++)
{
cout<<d[i].key<<"\t";
cout<<d[i].mean<<"\n";

}
getch();
}

bubble sort

# Program Name: Bubble Sort using python

#array[] contains the element that we want to sort
array = [2,5,4,1,7]

#BUBBLE SORT LOGIC

swapped = True
while (swapped):
     swapped = False
     for i in range(0,len(array)-1):
         if (array[i] > array[i+1]):
             temp = array[i]
             array[i] = array[i+1]
             array[i+1] = temp
             swapped = True

# PRINT THE SORTED ARRAY

print (array)

python program

def bubbleSort(alist):
    for passnum in range(len(alist)-1,0,-1):
        for i in range(passnum):
            if alist[i]>alist[i+1]:
                temp = alist[i]
                alist[i] = alist[i+1]
                alist[i+1] = temp

alist = [54,26,93,17,77,31,44,55,20]
bubbleSort(alist)
print(alist)


<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>

def insertionSort(alist):
   for index in range(1,len(alist)):

     currentvalue = alist[index]
     position = index

     while position>0 and alist[position-1]>currentvalue:
         alist[position]=alist[position-1]
         position = position-1

     alist[position]=currentvalue

alist = [54,26,93,17,77,31,44,55,20]
insertionSort(alist)
print(alist)


<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

def mergeSort(alist):
    print("Splitting ",alist)
    if len(alist)>1:
        mid = len(alist)//2
        lefthalf = alist[:mid]
        righthalf = alist[mid:]

        mergeSort(lefthalf)
        mergeSort(righthalf)

        i=0
        j=0
        k=0
        while i<len(lefthalf) and j<len(righthalf):
            if lefthalf[i]<righthalf[j]:
                alist[k]=lefthalf[i]
                i=i+1
            else:
                alist[k]=righthalf[j]
                j=j+1
            k=k+1

        while i<len(lefthalf):
            alist[k]=lefthalf[i]
            i=i+1
            k=k+1

        while j<len(righthalf):
            alist[k]=righthalf[j]
            j=j+1
            k=k+1
    print("Merging ",alist)

alist = [54,26,93,17,77,31,44,55,20]
mergeSort(alist)
print(alist)



<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

def quickSort(alist):
   quickSortHelper(alist,0,len(alist)-1)

def quickSortHelper(alist,first,last):
   if first<last:

       splitpoint = partition(alist,first,last)

       quickSortHelper(alist,first,splitpoint-1)
       quickSortHelper(alist,splitpoint+1,last)


def partition(alist,first,last):
   pivotvalue = alist[first]

Thursday, 17 September 2015

C++ Program to Implement AVL Trees

This C++ Program demonstrates operations on AVL Trees.
Here is source code of the C++ Program to demonstrate AVL Trees. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
  1. /*
  2.  * C++ program to Implement AVL Tree
  3.  */
  4. #include<iostream>
  5. #include<cstdio>
  6. #include<sstream>
  7. #include<algorithm>
  8. #define pow2(n) (1 << (n))
  9. using namespace std;
  10.  
  11. /*
  12.  * Node Declaration
  13.  */
  14. struct avl_node
  15. {
  16.     int data;
  17.     struct avl_node *left;
  18.     struct avl_node *right;
  19. }*root;
  20.  
  21. /*
  22.  * Class Declaration
  23.  */
  24. class avlTree
  25. {
  26.     public:
  27.         int height(avl_node *);
  28.         int diff(avl_node *);
  29.         avl_node *rr_rotation(avl_node *);
  30.         avl_node *ll_rotation(avl_node *);
  31.         avl_node *lr_rotation(avl_node *);
  32.         avl_node *rl_rotation(avl_node *);
  33.         avl_node* balance(avl_node *);
  34.         avl_node* insert(avl_node *, int );
  35.         void display(avl_node *, int);
  36.         void inorder(avl_node *);
  37.         void preorder(avl_node *);
  38.         void postorder(avl_node *);
  39.         avlTree()
  40.         {
  41.             root = NULL;
  42.         }
  43. };
  44.  
  45. /*
  46.  * Main Contains Menu
  47.  */
  48. int main()
  49. {
  50.     int choice, item;
  51.     avlTree avl;
  52.     while (1)
  53.     {
  54.         cout<<"\n---------------------"<<endl;
  55.         cout<<"AVL Tree Implementation"<<endl;
  56.         cout<<"\n---------------------"<<endl;
  57.         cout<<"1.Insert Element into the tree"<<endl;
  58.         cout<<"2.Display Balanced AVL Tree"<<endl;
  59.         cout<<"3.InOrder traversal"<<endl;
  60.         cout<<"4.PreOrder traversal"<<endl;
  61.         cout<<"5.PostOrder traversal"<<endl;
  62.         cout<<"6.Exit"<<endl;
  63.         cout<<"Enter your Choice: ";
  64.         cin>>choice;
  65.         switch(choice)
  66.         {
  67.         case 1:
  68.             cout<<"Enter value to be inserted: ";
  69.             cin>>item;
  70.             root = avl.insert(root, item);
  71.             break;
  72.         case 2:
  73.             if (root == NULL)
  74.             {
  75.                 cout<<"Tree is Empty"<<endl;
  76.                 continue;
  77.             }
  78.             cout<<"Balanced AVL Tree:"<<endl;
  79.             avl.display(root, 1);
  80.             break;
  81.         case 3:
  82.             cout<<"Inorder Traversal:"<<endl;
  83.             avl.inorder(root);
  84.             cout<<endl;
  85.             break;
  86.         case 4:
  87.             cout<<"Preorder Traversal:"<<endl;
  88.             avl.preorder(root);
  89.             cout<<endl;
  90.             break;
  91.         case 5:
  92.             cout<<"Postorder Traversal:"<<endl;
  93.             avl.postorder(root);    
  94.             cout<<endl;
  95.             break;
  96.         case 6:
  97.             exit(1);    
  98.             break;
  99.         default:
  100.             cout<<"Wrong Choice"<<endl;
  101.         }
  102.     }
  103.     return 0;
  104. }
  105.  
  106. /*
  107.  * Height of AVL Tree
  108.  */
  109. int avlTree::height(avl_node *temp)
  110. {
  111.     int h = 0;
  112.     if (temp != NULL)
  113.     {
  114.         int l_height = height (temp->left);
  115.         int r_height = height (temp->right);
  116.         int max_height = max (l_height, r_height);
  117.         h = max_height + 1;
  118.     }
  119.     return h;
  120. }
  121.  
  122. /*
  123.  * Height Difference 
  124.  */
  125. int avlTree::diff(avl_node *temp)
  126. {
  127.     int l_height = height (temp->left);
  128.     int r_height = height (temp->right);
  129.     int b_factor= l_height - r_height;
  130.     return b_factor;
  131. }
  132.  
  133. /*
  134.  * Right- Right Rotation
  135.  */
  136. avl_node *avlTree::rr_rotation(avl_node *parent)
  137. {
  138.     avl_node *temp;
  139.     temp = parent->right;
  140.     parent->right = temp->left;
  141.     temp->left = parent;
  142.     return temp;
  143. }
  144. /*
  145.  * Left- Left Rotation
  146.  */
  147. avl_node *avlTree::ll_rotation(avl_node *parent)
  148. {
  149.     avl_node *temp;
  150.     temp = parent->left;
  151.     parent->left = temp->right;
  152.     temp->right = parent;
  153.     return temp;
  154. }
  155.  
  156. /*
  157.  * Left - Right Rotation
  158.  */
  159. avl_node *avlTree::lr_rotation(avl_node *parent)
  160. {
  161.     avl_node *temp;
  162.     temp = parent->left;
  163.     parent->left = rr_rotation (temp);
  164.     return ll_rotation (parent);
  165. }
  166.  
  167. /*
  168.  * Right- Left Rotation
  169.  */
  170. avl_node *avlTree::rl_rotation(avl_node *parent)
  171. {
  172.     avl_node *temp;
  173.     temp = parent->right;
  174.     parent->right = ll_rotation (temp);
  175.     return rr_rotation (parent);
  176. }
  177.  
  178. /*
  179.  * Balancing AVL Tree
  180.  */
  181. avl_node *avlTree::balance(avl_node *temp)
  182. {
  183.     int bal_factor = diff (temp);
  184.     if (bal_factor > 1)
  185.     {
  186.         if (diff (temp->left) > 0)
  187.             temp = ll_rotation (temp);
  188.         else
  189.             temp = lr_rotation (temp);
  190.     }
  191.     else if (bal_factor < -1)
  192.     {
  193.         if (diff (temp->right) > 0)
  194.             temp = rl_rotation (temp);
  195.         else
  196.             temp = rr_rotation (temp);
  197.     }
  198.     return temp;
  199. }
  200.  
  201. /*
  202.  * Insert Element into the tree
  203.  */
  204. avl_node *avlTree::insert(avl_node *root, int value)
  205. {
  206.     if (root == NULL)
  207.     {
  208.         root = new avl_node;
  209.         root->data = value;
  210.         root->left = NULL;
  211.         root->right = NULL;
  212.         return root;
  213.     }
  214.     else if (value < root->data)
  215.     {
  216.         root->left = insert(root->left, value);
  217.         root = balance (root);
  218.     }
  219.     else if (value >= root->data)
  220.     {
  221.         root->right = insert(root->right, value);
  222.         root = balance (root);
  223.     }
  224.     return root;
  225. }
  226.  
  227. /*
  228.  * Display AVL Tree
  229.  */
  230. void avlTree::display(avl_node *ptr, int level)
  231. {
  232.     int i;
  233.     if (ptr!=NULL)
  234.     {
  235.         display(ptr->right, level + 1);
  236.         printf("\n");
  237.         if (ptr == root)
  238.         cout<<"Root -> ";
  239.         for (i = 0; i < level && ptr != root; i++)
  240.             cout<<"        ";
  241.         cout<<ptr->data;
  242.         display(ptr->left, level + 1);
  243.     }
  244. }
  245.  
  246. /*
  247.  * Inorder Traversal of AVL Tree
  248.  */
  249. void avlTree::inorder(avl_node *tree)
  250. {
  251.     if (tree == NULL)
  252.         return;
  253.     inorder (tree->left);
  254.     cout<<tree->data<<"  ";
  255.     inorder (tree->right);
  256. }
  257. /*
  258.  * Preorder Traversal of AVL Tree
  259.  */
  260. void avlTree::preorder(avl_node *tree)
  261. {
  262.     if (tree == NULL)
  263.         return;
  264.     cout<<tree->data<<"  ";
  265.     preorder (tree->left);
  266.     preorder (tree->right);
  267.  
  268. }
  269.  
  270. /*
  271.  * Postorder Traversal of AVL Tree
  272.  */
  273. void avlTree::postorder(avl_node *tree)
  274. {
  275.     if (tree == NULL)
  276.         return;
  277.     postorder ( tree ->left );
  278.     postorder ( tree ->right );
  279.     cout<<tree->data<<"  ";
  280. }

$ g++ avl_tree.cpp
$ a.out
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Tree is Empty
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 8
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
Root -> 8
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 5
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
Root -> 8
                5
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 4
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
                8
Root -> 5
                4
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 11
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
                        11
                8
Root -> 5
                4
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 15
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
                        15
                11
                        8
Root -> 5
                4
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 3
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
                        15
                11
                        8
Root -> 5
                4
                        3
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 6
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
                        15
                11
                        8
                                6
Root -> 5
                4
                        3
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 1
Enter value to be inserted: 2
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
                        15
                11
                        8
                                6
Root -> 5
                        4
                3
                        2
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 4
Preorder Traversal:
5  3  2  4  11  8  6  15  
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 5
Postorder Traversal:
2  4  3  6  8  15  11  5  
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 3
Inorder Traversal:
2  3  4  5  6  8  11  15  
 
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 2
Balanced AVL Tree:
 
                        15
                11
                        8
                                6
Root -> 5
                        4
                3
                        2
---------------------
AVL Tree Implementation
 
---------------------
1.Insert Element into the tree
2.Display Balanced AVL Tree
3.InOrder traversal
4.PreOrder traversal
5.PostOrder traversal
6.Exit
Enter your Choice: 6
 
 
------------------
(program exited with code: 1)
Press return to continue