Data Structures & AlgorithmsHardTCS NQT · Infosys
Problem: The binary search tree is built by inserting 8, 3, 10, 1, 6, 14, 4, 7, 13 in this order. How many nodes lie at the maximum depth of this tree (root at depth 0)?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
Count nodes per depth with a traversal carrying the depth, then report the count at the deepest level. Counting leaves instead of nodes at the deepest level gives a different number when depths differ.
More Coding Interview Problems questions
- Problem: A binary tree is given in level order with None for missing children: [1, 2, 3, None, 4, 5, None, 6]. In this array, node at…
- Problem: The right-side view of a binary tree lists the rightmost node at each depth from top to bottom. For the tree with root 1…
- Problem: A binary tree is given by level order [1, 2, 3, 4, 5, None, 6]. Its diameter is the largest number of edges on any path between…
- Problem: How many palindromic substrings of even length does "abbaccdd" contain?
- Problem: The string "aaaa" can be written as a concatenation of the pieces "a" and "aa" in several ways (order matters). How many such…
- Problem: The minimum ASCII delete sum to make the strings "sea" and "eat" equal is the least total ASCII value of deleted characters. Give…