C++ program to Create binary tree.Find height, mirror image,level-wise printing.
08:07Create binary tree.Find height, mirror image,level-wise printing.
OUTPUT:
1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)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)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :2
level Wise traversal on original tree
1
2 3
4 5 6 7
level Wise traversal on mirror tree
1
3 2
7 6 5 4
1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :3
7 6 5 4
No of leaf nodes= 4
1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :4
Height = 2
1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :5
0 comments: