Skip to content
Get started

Depth of a key in a BST

You insert the keys 8,3,10,1,6,14,4,7,138, 3, 10, 1, 6, 14, 4, 7, 13 in that order into an initially empty binary search tree (each key walks down from the root, going left if smaller and right if larger, until it hits an empty spot). At what depth does key 77 end up? (The root is at depth 00.)

Show hints (2)+
  1. Insert in the given order; each key walks left/right until an empty slot.
  2. Trace 77's path from the root: 8→3→6→78 \to 3 \to 6 \to 7.

Answer

Reveal answer →

3

Create a free account to see the full worked solution and track your progress.

Interview format: Market Maker, Trading Aptitude Tests

Related questions