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)?
- A. 4
- B. 5
- C. 3
- 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
- Problem: In the sorted array [−3, −1, 0, 1, 2, 3], how many pairs of distinct positions (i < j) have a sum of exactly 0?
- Problem: What is C(10, 3) modulo 7?
- Problem: How many prime numbers lie strictly between 100 and 150?
- Problem: The number of decimal digits in 100! is what value?
- Problem: What is gcd(462, 1071)?
- Problem: What is the determinant of the matrix [[2, 1], [1, 3]]?