Data Structures & AlgorithmsHardGATE CS
A BST holds integer keys between 1 and 100. Which sequence CANNOT be the sequence of keys examined while searching for 58?
- A. 18, 89, 11, 77, 62, 58
- B. 95, 62, 38, 51, 57, 58
- C. 54, 57, 94, 85, 58
- D. 27, 82, 70, 53, 58
Correct answer: A. 18, 89, 11, 77, 62, 58
Each probe narrows an interval (lo, hi) that must contain 58; every later key must lie strictly inside it. In 18, 89, 11, 77, 62, 58 one key falls outside the interval already fixed by an earlier ancestor.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- What is the length of the longest common subsequence of MATRIX and MARTIAN, and how many DISTINCT longest common subsequences (as strings)…
- Lectures occupy half-open intervals [start, end): [3, 10), [6, 10), [7, 12), [9, 11), [10, 15), [10, 17), [10, 18), [20, 25). A lecture…
- A binary max-heap is stored in a 0-indexed array [57, 47, 54, 14, 15, 6, 21]. Perform, in order: delete-max, insert 10, delete-max, insert…
- Keys 13, 30, 35, 39, 54 are searched with frequencies 8, 1, 9, 9, 12 respectively (only successful searches). The cost of a BST is Σ…
- A min-heap holds 63 distinct keys in a 0-indexed array (a full tree with 6 levels). At how many different indices can the 5th-smallest key…
- Keys 20, 94, 97, 28, 21, 78, 37, 93, 79, 36 are inserted into an empty AVL tree (giving preorder 78, 28, 21, 20, 37, 36, 93, 79, 94, 97)…