Skip to main content

Command Palette

Search for a command to run...

🌲 Trees Explained Like You're 5

Published
β€’1 min read
S

Building AI systems and writing about how they actually work. Master of AI @ University of Technology Sydney. Previously B.Tech CS with focus on IoT. I believe the best way to learn is to explain. That's why I'm documenting tech concepts with simple analogies (@sreekarreddy.com). AWS Certified β€’ Azure AI Certified β€’ Neo4j Professional β€’ Google Data Analytics When not coding: exploring Sydney, working on side projects, and teaching tech to anyone who'll listen.

A family tree with parent and children

Day 36 of 149

πŸ‘‰ Full deep-dive with code examples


The Family Tree

        Grandma
       /       \
     Mom       Uncle
    /   \        |
  You  Sister   Cousin

Each person has a "parent" and maybe "children."

Computer trees work exactly like family trees!


In Code

       CEO
      /    \
    CTO    CFO
   /   \     \
 Dev1  Dev2   Accountant
  • CEO is the root (top)
  • CTO and CFO are children of CEO
  • Dev1 and Dev2 are leaves (no children)

Why Use Trees?

Fast searching!

Binary Search Tree:

  • Every left child is smaller
  • Every right child is bigger
       5
      / \
     3   7
    / \   \
   1   4   9

To find 4: Go right of 3, done! Didn't check every node.


Real Uses

  • File systems (folders contain folders)
  • HTML (elements contain elements)
  • Decision trees in AI

In One Sentence

Trees organize data in a hierarchy of parent-child relationships, like a family tree or folder structure.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

More from this blog

esreekarreddy

132 posts