Trees - Programming Interview Questions

1. Write a C program to find the depth or height of a binary tree.

Click Here For Solution


2. Write a C program to determine the number of elements (or size) in a binary tree.

Click Here For Solution


3. Write a C program to delete a tree (i.e, free up its nodes)
Click Here For Solution


4. Write a C program to find the minimum value in a binary search tree.

Click Here For Solution

5. Write a C program to create a mirror copy of a tree (left nodes become right and right nodes become left)
Click Here For Solution

6. Write C code to implement the preorder(), inorder() and postorder() traversals. Whats their time complexities?
Click Here For Solution
7. Write a C program to create a copy of a tree
Click Here For Solution

8. Write a C program to check if a given binary tree is a binary search tree or not?
Click Here For Solution

9. Write a C program to implement level order traversal of a tree.
Solution:Breadth First Search of the tree gives the level order traversal.

10. Write a C program to delete a node from a Binary Search Tree?
Click Here For Solution

11. Write a C program to search for a value in a binary search tree (BST).
Click Here For Solution
12. Write a C program to count the number of leaves in a tree
Click Here For Solution
13. Write a C program for iterative preorder, inorder and postorder tree traversals
Solution:Use stacks to depict the function calls.Not much different from routine traversals.

1 comment:

  1. Informative Post...

    Good Job......

    http://updated-info-india.blogspot.com

    ReplyDelete