Trees and Binary Trees — Kids' Family Tree Fun!

Published: (December 10, 2025 at 09:17 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Cover image for Trees and Binary Trees — Kids' Family Tree Fun!

Trees: The Happy Family Chart

A tree is like your family photo album. There’s one grandparent (root) at the top, then they have kids, and those kids have their own kids. Everything grows downward from the top!

Everyday examples

  • School teams: teacher (top) → group leaders → friends
  • Computer folders: “My Computer” (top) → Pictures → My Drawings

Draw a simple tree

     Grandpa
    /      \
  Dad     Uncle
 /  \       \
Tom  Lily   Jack

Grandpa is the boss — you find Tom through Dad!

Binary Trees: Max Two Kids Per Parent

A binary tree is a special tree where every parent has at most two kids (one left, one right). Like families with twins!

Everyday examples

  • Guessing games: Guess 50? Too high → try 25? Too low → try 37!
  • Yes/no choices: Left or right path? Pick left → another left/right

Super easy code to try (Python)

# Tree like family members
class FamilyMember:
    def __init__(self, name):
        self.name = name
        self.left_kid = None   # Left child
        self.right_kid = None  # Right child

# Build family tree
grandpa = FamilyMember("Grandpa")
dad = FamilyMember("Dad")
tom = FamilyMember("Tom")

grandpa.left_kid = dad      # Grandpa's left is Dad
dad.left_kid = tom          # Dad's left is Tom

print("Grandpa's left kid:", grandpa.left_kid.name)  # Dad
print("Dad's left kid:", dad.left_kid.name)          # Tom

How to Play the Family Tree Game?

Get ready

  1. Open Python on your computer (or use python.org online).
  2. Save the code above as family_tree.py.
  3. Run it with python family_tree.py in the command line.

What you’ll see

Grandpa's left kid: Dad
Dad's left kid: Tom

Add “Lily” as Dad’s right kid and watch the tree grow!

Where Do Trees Help in Real Life?

  • Trees: Company teams, menu navigation (File → Pictures → My Art).
  • Binary Trees: Super‑fast searches (like dictionary look‑ups), game decision trees.

You’re a family‑tree artist now! Draw your own family or tweak the code with more relatives. So much fun! 🌳✨

Back to Blog

Related posts

Read more »