A tree is a hierarchical data structure with a root node and child nodes forming parent-child relationships. Each node has zero or more children, and there's exactly one path between any two nodes. Trees model file systems, HTML DOM, organizational charts, and database indexes.

How Tree Works

File system: root (/) → home → user → documents → file.txt. HTML DOM: html → body → div → p → text. Binary Search Tree: sorted data with O(log n) lookup, insertion, and deletion. Database B-trees: indexes that enable fast queries on billions of rows.

Key Concepts

  • Root — The topmost node — every tree has exactly one root
  • Parent/Child — Each node (except root) has one parent; nodes can have zero or more children
  • Leaf — A node with no children — the endpoints of the tree
  • Depth/Height — Depth: distance from root to a node. Height: longest path from a node to a leaf

Learn Tree — Top Videos

Tree Educators

Gate Smashers
Gate Smashers

@gatesmashers

Web Dev

Welcome to Gate Smashers, one of the fastest-growing EdTech communities with 2.6 M+ learners. 🎓 We provide complete lec...

2.7M Subs
2.1K Videos
8.6K Avg Views
4.33% Engagement
View Profile →
NeetCode
NeetCode

@neetcode

CS

Preparing for technical interviews? Checkout neetcode.io

1.1M Subs
432 Videos
42K Avg Views
2.87% Engagement
View Profile →
NeuralNine
NeuralNine

@neuralnine

AI Coding

NeuralNine is an educational brand focusing on programming, machine learning and computer science in general! Let's deve...

471K Subs
1K Videos
6.2K Avg Views
4.65% Engagement
View Profile →

Frequently Asked Questions

Trees vs graphs?

Trees are a special type of graph: connected, acyclic, with one root. Graphs can have cycles, multiple components, and no root. Trees model hierarchies; graphs model networks.