175 views
0 0 votes

Consider the Merge Sort algorithm being applied to an array of $n$ elements. Which of the following statements is/are TRUE regarding its operational characteristics?

  1. Merge Sort is a stable sorting algorithm.
     
  2. The space complexity of the standard array-based implementation is $O(1)$.
     
  3. The worst-case time complexity is $O(n \log n)$.
     
  4. It is an "in-place" sorting algorithm.

 

  1. i and iii only
     
  2. i, ii, and iii only
     
  3. iii and iv only
     
  4. i, iii, and iv only

1 Answer

0 0 votes

Statement i is TRUE: Merge Sort is stable because it preserves the relative order of equal elements during the merging process (provided the logic handles the left sub-array first).

Statement ii is FALSE: The standard implementation of Merge Sort requires an auxiliary array of size $n$ to perform the merge step, leading to a space complexity of $O(n)$, not $O(1)$.

Statement iii is TRUE: Merge Sort consistently divides the array in half ( $\log n$ levels) and performs $O(n)$ work at each level to merge. This holds true for the best, average, and worst cases, resulting in $O(n \log n)$.

Statement iv is FALSE: An "in-place" algorithm is one that requires a constant amount of extra space. Since Merge Sort requires $O(n)$ extra space, it is not considered an in-place algorithm

Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
154
154 views
GO Classes asked Feb 21
154 views
What is the output of the following Python code snippet?def modify_list(lst): lst.append([3, 4]) lst = [7, 8] return lst my_list = [1, 2] new_list = modif...
1 1 vote
1 1 answer
136
136 views
GO Classes asked Feb 21
136 views
Consider a Directed Acyclic Graph (DAG). If you perform a Depth First Search (DFS) on this graph and record the "finish times" of each vertex (the time at which the recur...
0 0 votes
1 1 answer
116
116 views
GO Classes asked Feb 21
116 views
Suppose you are searching for the value $X=35$ in a sorted array $A= [10,20,30,40,50,60,70]$ using the Binary Search algorithm. If the algorithm uses the formula mid $=l ...
1 1 vote
1 1 answer
162
162 views
GO Classes asked Feb 21
162 views
Consider a scenario where you are given a stack $S$ and an empty queue $Q$. You perform the following sequence of operations:Push elements $10,20,30,40$ into $S$ in that ...