Use the tree constructed in question 1 to print all the leaf nodes in inorder fashion, also calculate the height of the tree. Input format and constraints are same as question 1.
Output Format:
In first line print the leaf nodes in inorder fashion.
In second line print the height of the tree.
For given input constructed tree will look like the following:
6
/ \
3 8
/ \ / \
2 5 7 9
/ / \
1 4 10
Hence leaf nodes in inorder fashion are 1 4 7 10.
And height of tree is 4.