Skip to main content

Binary Search Tree

Each node stores a key. A smaller key always hangs to the left of its parent, and a larger key hangs to the right, so a search follows one downward branch.

In the picture

  1. The top ball: the root key where a search begins
  2. The down-left ball: a key smaller than its parent
  3. The down-right ball: a key larger than its parent
  4. The glowing stick: the chosen branch taken at the root
  5. The glowing bottom ball: the key reached after one branch at each step

Examples

  • Finding a contact by name in a phone app by comparing and following one branch.
  • Locating a product by its ID in an online store by going left or right.

Quiz: Binary Search Tree (Age 18)

  1. In a binary search tree, what does a node’s left subtree contain?

    • Keys both smaller and larger than the node’s key
    • Only keys larger than the node’s key
    • Only keys smaller than the node’s key
  2. Where does a search in a binary search tree begin?

    • At any leaf chosen at random
    • At the root key
    • At the smallest key in the tree
  3. During a search in a binary search tree, how does the search move through the tree?

    • It follows one downward branch at each step
    • It checks every node on each level
    • It jumps directly to the largest key

The answers, each with its explanation, are in the app. This lesson has left the free week, so its quiz is part of the subscription.

Get the app

Free app, optional subscription
App Store Google Play

Carry on in the app

At least one new illustrated lesson every weekday for your child’s year, with its quiz and a reminder at 6:15 pm.

Your child’s teacher does not use My Enhanced Teacher yet?

Tell them about it

Age 18