c++ program Create binary tree and perform recursive and non-recursive traversal
08:05Create binary tree and perform recursive and non-recursive traversal
OUTPUT:
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :1
Enter a data(-1 for no data or Null node ) : 1
Enter left child of 1
Enter a data(-1 for no data or Null node ) : 2
Enter left child of 2
Enter a data(-1 for no data or Null node ) : 4
Enter left child of 4
Enter a data(-1 for no data or Null node ) : -1
Enter right child of 4
Enter a data(-1 for no data or Null node ) : -1
Enter right child of 2
Enter a data(-1 for no data or Null node ) : 5
Enter left child of 5
Enter a data(-1 for no data or Null node ) : -1
Enter right child of 5
Enter a data(-1 for no data or Null node ) : -1
Enter right child of 1
Enter a data(-1 for no data or Null node ) : 3
Enter left child of 3
Enter a data(-1 for no data or Null node ) : 6
Enter left child of 6
Enter a data(-1 for no data or Null node ) : -1
Enter right child of 6
Enter a data(-1 for no data or Null node ) : -1
Enter right child of 3
Enter a data(-1 for no data or Null node ) : 7
Enter left child of 7
Enter a data(-1 for no data or Null node ) : -1
Enter right child of 7
Enter a data(-1 for no data or Null node ) : -1
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :2
1 2 4 5 3 6 7
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :3
4 2 5 1 6 3 7
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :4
4 5 2 6 7 3 1
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :5
4 2 5 1 6 3 7
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :6
1 2 4 5 3 6 7
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :7
4 5 2 6 7 3 1
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :8
0 comments: