C++ program to Create a TBT and perform traversals


Create a TBT and perform traversals



OUTPUT:

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 1

 Enter a data(-1 for no data or NULL child ) : 1

Enter left child of 1
 Enter a data(-1 for no data or NULL child ) : 2

Enter left child of 2
 Enter a data(-1 for no data or NULL child ) : 4

Enter left child of 4
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 4
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 2
 Enter a data(-1 for no data or NULL child ) : 5

Enter left child of 5
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 5
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 1
 Enter a data(-1 for no data or NULL child ) : 3

Enter left child of 3
 Enter a data(-1 for no data or NULL child ) : 6

Enter left child of 6
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 6
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 3
 Enter a data(-1 for no data or NULL child ) : 7

Enter left child of 7
 Enter a data(-1 for no data or NULL child ) : -1
Enter right child of 7
 Enter a data(-1 for no data or NULL child ) : -1


1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 2

  1  2  4  5  3  6  7

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 3

   4   2   5   1   6   3   7

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 4
   4   5   2   6   7   3   1

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 5