Data Structures & AlgorithmsHardGATE CS · Product-company placement
A BST holds integer keys between 1 and 100. Which sequence CANNOT be the sequence of keys examined while searching for 46?
- A. 30, 35, 38, 44, 46
- B. 98, 84, 8, 38, 46
- C. 12, 95, 5, 84, 41, 46
- D. 64, 34, 58, 52, 46
Correct answer: C. 12, 95, 5, 84, 41, 46
Each probe narrows an interval (lo, hi) that must contain 46; every later key must lie strictly inside it. In 12, 95, 5, 84, 41, 46 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
- Dijkstra's algorithm runs from A on the directed graph A→B (6), A→E (1), A→F (11), B→C (9), B→D (2), B→F (1), C→D (10), C→F (11), D→A (5)…
- With 3 identical eggs and at most 7 drops, what is the largest number of floors for which you can always determine the critical floor (the…
- 0/1 knapsack with capacity 18: items (weight, value) = (8, 39), (2, 16), (3, 24), (6, 38), (3, 36). What is the maximum total value?
- Six sorted files have 8, 23, 33, 38, 42, 49 records. Merging two files of sizes a and b costs a + b. What is the minimum total cost to…
- Kruskal's algorithm runs on the weighted undirected graph A–B (15), A–F (7), A–G (21), B–C (17), B–D (23), B–F (22), D–F (8), E–F (13)…
- A complete binary tree (array form, all levels full except possibly the last, which is filled from the left) has 131 nodes. How many…