Suppose merge sort algorithm is run on the following vector: 5, 301, 101, 100, 102, 302, 1 Which of the following is the correct sorted output (ascending)? a. 1, 5, 102, 101, 301, 302, 100 b. 1, 5, 101, 102, 302, 301, 100 c. 1, 5, 101, 102, 301, 302, 100 d. 1, 5, 301, 302, 101, 102, 100
Suppose merge sort
5, 301, 101, 100, 102, 302, 1
Which of the following is the correct sorted output (ascending)?
a. 1, 5, 102, 101, 301, 302, 100
b. 1, 5, 101, 102, 302, 301, 100
c. 1, 5, 101, 102, 301, 302, 100
d. 1, 5, 301, 302, 101, 102, 100
- The question wants to have the correct output for merge sort in ascending order.
- Here we have merge sort algorithm working on the given vector which is to be sorted in ascending order.
- The algorithm sorts the vector in ascending order using the divide and conquer methodology.
- The first option has 102 ahead of 101 which is not sorted, So, this option is incorrect.
- The second option has 302 ahead of 301 which is not sorted, So, this option is incorrect.
- The third option has 302 ahead of 100 which is not sorted, So, this option is incorrect.
- The fourth option has 302 ahead of 101 which is not sorted, So, this option is incorrect.
- The correct output should have been 1,5,100,101,102 ,301,302.
Step by step
Solved in 2 steps