A tree represents a hierarchy. A family tree, a folder system, and an organization chart all have a starting point with branches below it.
Useful tree vocabulary
The top node is the root. A node's children are below it; nodes with no children are leaves. The number of edges from the root to a node is its depth. The height is the length of the longest path from a node down to a leaf.
A binary tree allows each node to have at most two children. In a binary search tree, values in the left subtree are smaller than the node and values in the right subtree are larger (or follow a consistent duplicate rule).
Searching depends on balance
At each step in a binary search tree, compare the target with the current node and continue into at most one subtree. A well-balanced tree with n nodes has height around log₂(n), so search is O(log n). If values arrive in sorted order and the tree is not self-balancing, it can become a chain with height n and search becomes O(n).
Walk the tree
Depth-first traversals visit nodes by going down branches; breadth-first traversal visits level by level. An in-order traversal of a binary search tree visits values in sorted order.
Trees are useful whenever data is naturally hierarchical or needs ordered lookup. In production, balanced variants such as AVL trees and red-black trees preserve predictable height as values change.