Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment:

Binary Search Tree 1

1. Create Binary Search Tree Class with all functions discussed


2. Implement copy constructor, assignment operator and destructor for
Generic Tree, Binary Tree and BST.
3. Find In-order Successor of a node in BST
4. Given a Binary Tree, check if it is a BST or not
5. Given a BST, print all elements in range K1 and K2
6. Given preorder traversal of a BST, construct BST.
7. Build a balanced BST using sorted array
8. Given a binary search tree and a number s, find pair of nodes in the BST
which sum to s. Time Complexity Expected O(n)
9. Find least common ancestor (LCA) of a binary search tree.
10. Given a Binary tree, find the largest BST subtree. i.e. find the largest
subtree which is a BST
11. Given a binary tree. Print the zig zag order i.e print level 1 from left to
right, level 2 from right to left and so on. This means odd levels should get
printed from left to right and even levels should be printed from right to
left. Each level should be printed at a new line
12. Given a binary tree print all nodes that dont have a sibling
13. Given a Binary tree check if it is balanced i.e. depth of the left and
right subtrees of every node differ by 1 or less
14. Pretty Print a Binary tree. (Hint: Find the height of the tree first)

You might also like