Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: Heap-indexed binary tree with 10 nodes (node i has children 2i and 2i+1 when ≤ 10). How many nodes lie at depth 2 (root at depth 0)?

  1. A. 4
  2. B. 5
  3. C. 3
  4. D. 6

Correct answer: A. 4

Depth 2 contains indices 4 to 7 in heap order, which is four nodes.

More Coding Interview Problems questions

Exams that ask this topic