🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Binary Search Tree Operations: questions with answers

15 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. In a binary search tree, which statement is always true for every node?
  2. Q2. What does this print? (code)
  3. Q3. Keys 1, 2, 3, 4, 5 are inserted in that order into an empty plain BST. What is the height of the tree?
  4. Q4. A node to be deleted has two children. Which key replaces it?
  5. Q5. Why does the inorder successor of a node with two children never have a left child?
  6. Q6. Root 10 has left child 5, and 5 has right child 12. Is this a valid BST?
  7. Q7. What does this print? (code)
  8. Q8. What is the time complexity of searching a balanced BST with n keys?
  9. Q9. To find the k-th smallest key in a BST, the simplest correct method is to:
  10. Q10. Why are Java's TreeMap operations guaranteed O(log n) while a plain BST is not?
  11. Q11. What does this print? (code)
  12. Q12. How do you delete a node that has exactly one child?
  13. Q13. What does this print? (code)
  14. Q14. What is a correct way to check that a binary tree is a valid BST?
  15. Q15. Why does inserting already sorted keys into a plain BST make operations slow?