Trees & Binary Search Trees
What a tree actually is - nodes, root, children, leaves - then the binary search tree specifically: the ordering rule that makes search and insert fast, with real code building and searching one.
Download EPUB- What a Tree Is A tree is nodes connected in a branching, one-parent-per-node shape: a root at the top, children below it, leaves where the branching stops. File systems, org charts, and the DOM are all trees wearing different clothes.
- Binary Search Trees A binary search tree adds one rule to a tree: every node's left subtree holds smaller values, its right subtree holds bigger ones. That single invariant is what makes searching and inserting fast - real code building and searching one.
- BST Performance & Gotchas A binary search tree is O(log n) when balanced - but inserting already-sorted data can degrade it into a lopsided chain with O(n) search, no better than a linked list. Real code and the fix: self-balancing trees.