Question Bank

Binary Tree Basics Quiz

Difficulty: Easy

Short prompts on node anatomy, depth vs height, and leaf counting. Foundation drills before tackling traversal, BSTs, or balanced tree problems.

Question Bank
/

Binary Tree Basics Quiz

Binary Tree Basics Quiz

Short prompts on node anatomy, depth vs height, and leaf counting. Foundation drills before tackling traversal, BSTs, or balanced tree problems.

Question Bank
Easy
JavaScript
3 questions
binary-tree
data-structures
quiz
fundamentals

1,121 views

9

For the tree built below, identify (a) the root, (b) every leaf, (c) the height of the tree, and (d) the depth of node 5.

Examples

Example 1:

Input: tree 1 with left subtree (2 -> (4, 5)) and right subtree (3 -> (null, 6))
Output: root = 1; leaves = {4, 5, 6}; height (edges) = 2; depth(5) = 2
Explanation: Root is the topmost node. Leaves are nodes with no children. Counting in edges, the root sits at height 2 and leaves at 0. Node 5 is two edges from the root.