GATE Computer ScienceVery hardGATE CSE · NIELIT
Top-down merge sort (split at ⌊n/2⌋, standard merge that stops comparing once one list is exhausted) sorts [38, 27, 43, 3, 9, 82, 10, 15, 71, 6, 50]. How many key comparisons are made in total?
- A. 24
- B. 27
- C. 29
- D. 32
Correct answer: B. 27
Summing the comparisons over each merge in the recursion tree gives 27.
More Algorithms questions
- A DFS is run on a directed graph with adjacency lists 0:[1,4], 1:[2,5], 2:[0,3], 3:[1], 4:[5,6], 5:[3], 6:[4,5], 7:[3,6]. Vertices are…
- In how many different ORDERED sequences of coins from {1, 4, 5} can a total of exactly 15 be formed (sequences like 1,4 and 4,1 count…
- How many binary strings of length 12 do not contain three consecutive 1s as a substring?
- Five keys k1<k2<k3<k4<k5 are searched with access frequencies 4, 2, 6, 3, 9. For a binary search tree over these keys, with the root at…
- What is the minimum number of comparisons needed in the worst case to find the SECOND smallest of 100 distinct elements?
- Consider T(n) = 2T(n/2) + n/log₂n for n ≥ 2 (n a power of 2, T(1) = 1). Which is the tightest bound? (The Master theorem in its basic form…