Trees

IB Computer Science HL

Lesson 1: Introduction, Logic & Terminology

Explore foundational tree concepts, terminology, and BST properties through classroom-ready activities.

Lesson Objectives

  • Explain the logical structure of a tree using real-world examples.
  • Define and identify the root, parent, child, leaf, and subtree on a diagram.
  • Construct a physical Binary Search Tree (BST) from a given set of data.
↓ Next Activity

Activity 1: The Human Tree

(20 minutes)

Let's build a tree using people! We'll use this to learn the core terminology.

Root
Left-Child
Right-Child
Leaf
Leaf

Key Terms

  • Root: The single top-most node.
  • Parent: A node with children.
  • Left/Right-Child: Nodes below a parent.
  • Leaf: A node with NO children.
  • Subtree: A parent and all its descendants.

Recursive Thinking

How can we describe a tree? "A tree is a root node, connected to a left subtree and a right subtree."

A subtree is just a smaller tree. The structure is defined in terms of itself!

↓ Next Activity

Interactive Definitions

(15 minutes)

Hover over the "flash cards" to see the definition and highlight the corresponding part of the tree!

A B C D E

Root

The single top-most node of the tree. (A)

Parent

Any node that has at least one child. (A, B)

Child

A node connected directly below a parent. (B, C, D, E)

Leaf

A node with no children. (C, D, E)

Subtree

A parent node and all of its descendants. (The tree starting from B)

↓ Next Activity

Activity 3: Cup-Stacking BSTs

(25 minutes)

The Golden Rule

Start at the root. If the new number is LESS THAN the node, go LEFT.

If it's GREATER THAN, go RIGHT.

Repeat until you find an empty spot!

Let's Build!

In your groups, add these numbers one by one using your cups:

[ 50, 30, 70, 20, 40, 80 ]
↓ Next Activity

Exit Ticket: Label the Tree

(10 minutes)

Using the tree diagram, complete the following tasks:

  • 1. Circle the root.
  • 2. Put a square around all the leaves.
  • 3. Shade the entire right-subtree of the root.
  • 4. Draw an arrow from one parent to its left-child.
10 5 15 2 20

Well Done!

Next lesson, we will learn how to walk through these trees and modify them.

↑ Back to Top