binary trees Flashcards
What is the depth of a tree?
The depth of a tree is the maximum depth of any leaf node.
What are the characteristics of a full binary tree?
- Every leaf node is at the same depth.
- Each non-leaf node has two children.
- A full binary tree of depth n has: 2^n leaves, 2^(n+1) - 1 nodes
What are the characteristics of a complete binary tree?
All levels are fully filled except possibly the last. Nodes at the deepest level are as far left as possible.
How many leaves and total nodes can a complete binary tree of depth n have?
At most 2^n leaves, Up to 2^(n+1) - 1 nodes
What’s the difference between a full binary tree and a complete binary tree?
A full binary tree has all leaves at the same depth and every non-leaf node has exactly two children. A complete binary tree may have a partially filled last level, but the nodes are as far left as possible.
How many leaves and total nodes are in a full binary tree of depth n?
A full binary tree of depth n has exactly 2^n leaves and up to 2^(n+1) - 1 nodes.