Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE
Two sorted lists [3, 5, 12, 13, 20, 31] and [3, 8, 10, 26, 27, 34, 39] are merged using the standard merge step. How many element comparisons are made?
- A. 10
- B. 9
- C. 6
- D. 11
Correct answer: D. 11
Compare heads until one list is exhausted; the leftover tail is copied without comparison. Comparisons = 11.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Evaluate the postfix expression: 8 8 2 + 3 1 + 8 +
- How many swaps does bubble sort (adjacent swaps, ascending) make on [44, 48, 59, 38, 4, 32, 49]?
- A sorted array holds the 15 values 2, 5, 8, … (step 3). Binary search with mid = ⌊(lo+hi)/2⌋ and 0-based indices looks for 11. How many…
- Keys 76, 92, 75, 39, 73, 79, 41, 56, 14 are inserted into a hash table of size 11 with h(k) = k mod 11 and linear probing. At which index…
- A circular queue is implemented in an array of size 10 with front = 6 and rear = 6 (rear indexes the last stored element, the queue is…
- Two sorted lists [6, 8, 12, 35] and [4, 11, 17, 20, 25, 29] are merged using the standard merge step. How many element comparisons are made?