Trees - commonly asked interview questions!

1) How do you create the mirror copy of a tree (left node becomes right and viceversa)

2)How do you build a tree given inorder and postorder traversals of it?

3)How do you build a tree given inorder and preorder traversals of it?

4)Can you build a tree given preorder and postorder traversals?If yes, then give the procedure.If no,then give a reason as to why?

5)Find the closest ancestor of a 2 given nodes in a binary search tree(use the property of binary search tree)?
6)How do you implement trees in array?

7)How many binary trees can be constructed from N nodes?(the structure of the tree is debated question)

8)How do you find the greatest and least among leaves?

9)How do you check whether a tree and it mirror image are equal?

10)How do you find the minimum and maximum elements in a binary search tree?

AVL Trees

11)How is an AVL tree different from normal binary tree?

12)Give an expression for the minimum no of nodes of a AVL tree of height H?

13)Give the operations required to convert a normal binary tree in to a AVL tree?

14)How many bits are required per node to store the height of a node in a N-node AVL tree?

15)Keys 1,2,3,........,2^k -1 are inserted in order into an initially empty AVL tree.
Prove that the resulting tree is perfectly balanced.

16)Write routines for all the rotations employed in AVL trees?

17)What is the smallest AVL tree that overflows an 8-bit height counter?

18)Write a function to generate a perfectly balanced binary search tree of height H with distinct keys 1 through 2^(H+1)-1 ?Give also the running time of the above function?

19)What are the complexities of insertion,deletion and search on an AVL tree?

20)Write routines for insertion,deletion in an AVL tree?


  1. answers plssssssssssssssssssss

  2. Someone plz provide the answers...