Explain the characteristics of a binary tree.
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: easy
Interview Round: Other
Explain the characteristics of a binary tree.
Cover the properties that follow from the definition and the common kinds of binary tree.
```hint Count by level
Ask how many nodes can sit at each depth, and what that tells you about the height of a tree with n nodes, at best and at worst.
```
### What a Strong Answer Covers
- The structural definition, including what makes the two children distinct
- Numeric properties that link nodes, edges, levels, height and leaves
- The common shapes (full, complete, perfect, balanced, degenerate) and how they differ
- How a binary search tree differs from a general binary tree
- How a binary tree is represented and traversed
### Follow-up Questions
- Why can a complete binary tree be stored in an array without pointers, and what are the index formulas for children and parent?
- What is the height of a binary tree with n nodes in the best and worst case, and why does that matter for a binary search tree?
- Show that in any binary tree the number of leaves is one more than the number of nodes with two children.
- Given preorder and inorder traversals, can you rebuild the tree uniquely? What about preorder and postorder?
Overview: Asks you to explain the defining properties of a binary tree beyond the basic definition. Tests whether you know the node, edge, height and leaf relationships, can tell full, complete, perfect, balanced and degenerate trees apart, and can separate a general binary tree from a binary search tree.