🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Binary Trees & BST Quiz: all 8 questions

Binary Trees & BST Quiz · Question 6 of 8

Why is checking only left.val < node.val < right.val NOT enough to validate a BST?

Why is checking only left.val < node.val < right.val NOT enough to validate a BST?

  1. A.Every node must also respect limits set by all its ancestors, not just its parent
  2. B.Because BSTs can't have negative values
  3. C.Because it's too slow
  4. D.It is enough
Answer & explanation

Correct answer: Every node must also respect limits set by all its ancestors, not just its parent

A node deep in the left subtree must still be smaller than the root — pass down a (min, max) range.

Can you get the rest right without peeking?

Take the timed Binary Trees & BST Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →