Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE
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?
- A. 4
- B. 14
- C. 9
- D. 10
Correct answer: C. 9
Compare heads until one list is exhausted; the leftover tail is copied without comparison. Comparisons = 9.
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: 4 3 5 + 3 -
- How many swaps does bubble sort (adjacent swaps, ascending) make on [33, 25, 8, 52, 16, 15, 22, 24, 10]?
- A sorted array holds the 39 values 2, 5, 8, … (step 3). Binary search with mid = ⌊(lo+hi)/2⌋ and 0-based indices looks for 50. How many…
- Keys 81, 58, 72, 25, 31 are inserted into a hash table of size 10 with h(k) = k mod 10 and linear probing. At which index is 58 stored?
- A circular queue is implemented in an array of size 7 with front = 4 and rear = 5 (rear indexes the last stored element, the queue is…
- Two sorted lists [6, 16, 24, 29] and [20, 22, 25, 35] are merged using the standard merge step. How many element comparisons are made?