Trees -Basic Interview Questions

We will start of with some basic questions on trees and this post will be updated with tougher questions to crack..

Basic Questions

1)If a tree has N nodes, then how many are the edges?

2)Prove that there exists only a single path from each node to the root?

3)Prove that the depth of a tree is always equal to the height of the tree?

4)The structure of a typical tree is to have in each node ,besides it data, a pointer to each of its children.But this might be infeasible if there aren’t fixed number of children at each node.So how do modify this data structure to accommodate variable no of children at each node?


5)What are the maximum and minimum depths of a binary search tree?

6)How many are the no of null pointers for a binary tree of N nodes?

7)Distinguish inorder , preorder and postorder traversals properly?

8)How is a binary tree different from binary search tree?

9)Recursive calls have always been employed in the case of trees because of their recursive structural property.But linked lists aren’t that different .But why recursion is not that advisable in the case of lists?(A little theoretical …. Think in terms of limited stack size of your machine)

10)What are the complexities of insertion,deletion on a binary search tree?

11)Show that the maximum number of nodes in a binary tree of height H is 2^(H+1) -1

Click Here For Solutions

1 comment: