A binary search tree (BST) is a binary tree whose nodes follow an ordering rule: every value in a node’s left subtree is smaller, and every value in its right subtree is larger. Each node has at most two children. section 8.2
Searching for a value
To find 7 in a tree rooted at 10, compare 7 with 10 and move left. At 5, compare again and move right to find 7. To search for 8, follow the same path; the missing value would occupy the next appropriate position. Each comparison discards an entire subtree. section 8.2
A BST combines the fast searching associated with sorted data and the flexible insertion associated with linked structures. Its performance depends on height: a short tree supports O(log n) searches, while repeatedly inserting larger values can produce a one-sided tree with height O(n). section 8.2 section 8.3
Use the tree diagrams to trace comparisons, subtree choices, and the path taken during a search. section 8.2
Balancing keeps the height near O(log n). AVL trees are self-balancing BSTs that update heights and balance factors after insertion, then use rotations when necessary; they provide O(log n) searches and insertions. section 8.6




