1.Binary tree
A binary tree is a tree where every node has AT MOST two children, conventionally called left and right — there is no ordering rule between them, unlike a binary search tree.
Key features
- A node with zero children is a leaf; a node with exactly one child is common and perfectly valid — a binary tree is not required to be "full" or "complete"
- Building one by hand is just nesting TreeNode(value, left, right) calls — the same shape a linked list's Node(value, next) nesting takes
- Almost every binary-tree function has the same skeleton: handle None as the base case, then combine the results of the left and right recursive calls
Every binary-tree function needs a None base case first — a real node always bottoms out at a missing child, and that is exactly where the recursion has to stop instead of dereferencing it.