Label the parts of a tree
Warm-up · Match the pairs · about 3 min
Look at the tree in the example. Match each term to the node or number it describes.
Example 1
Input:
{"levelOrder":[1,2,3,4,5,null,6,null,null,7]}
Output:
see the pairs
1 is at the top. 4, 7 and 6 have no children.
Constraints
- Each term matches exactly one item
Learn the idea first: Trees: root, leaf, depth, height, subtree, a visual lesson.
More Trees: root, leaf, depth, height, subtree problems
- Compute the height Warm-up
- Count the leaves Standard
- Height of a binary tree Standard
- Count the leaves in code Standard
- Count the nodes at depth d Standard
- Nodes at depth d in a full tree Challenge