retagged by
4,543 views
1 votes
1 votes
Given the following list of numbers:

[21, 1, 26, 45, 29, 28, 2, 9, 16, 49, 39, 27, 43, 34, 46, 40]

which answer illustrates the list to be sorted after 3 recursive calls to mergesort?

[16, 49, 39, 27, 43, 34, 46, 40]
[21,1]
[21, 1, 26, 45]
[21]
retagged by

2 Answers

Best answer
5 votes
5 votes

when the mergesort firstly runs it breaks the list in two parts

part1 = 21, 1, 26, 45, 29, 28, 2, 9

part2 = 16, 49, 39, 27, 43, 34, 46, 40

now first recursive call will take part1 as input and break into again two parts

part1.a = 21, 1, 26, 45

part1.b =  29, 28, 2, 9

now second recursive call will take part1.a  as input and break into again two parts

part1.a.1 =  21, 1

part1.a.2 = 26, 45

now third recursive call will take part1.a.1 as input and break into again two parts

part1.a.1.x =  21

part1.a.1.y =  1

so answer is 21

edited by
2 votes
2 votes

answer is D)

edited by

Related questions

0 votes
0 votes
0 answers
1
Rahul_Rathod_ asked Jan 16, 2019
512 views
is mergesort inplace on linked list?it is not inplace on array
0 votes
0 votes
0 answers
2
Ujjal Das asked Mar 17
133 views
Calculate the minimum and maximum number of element comparisons involved in 2 way merge sort assuming n is power of 2.