Software-Engineering
December 11, 2023Question 14070 – NIC-NIELIT Scientist-B 2020
December 11, 2023Question 14074 – NIC-NIELIT Scientist-B 2020
If one uses straight two-way merge sort algorithm to sort the following elements in ascending order 20, 47, 15, 8, 9, 4, 40, 30, 12, 17 then the order of these elements after the second pass of the algorithm is:
Correct Answer: B
Question 92 Explanation:
Merge sort divides the node until the node itself is sorted. In the merging process two nodes are compared bcz of two way merge. Pass1:(20,47), (8,15), (4,9), (30,40), (12,17)
Pass2: (8,15,20,47), (4,9,30,40), (12,17)
Pass3: (4,8,9,15,20,30,40,47),(12,17)
Pass4: (4,8,9,12,15,17,20,30,40,47)
So within 4 passed we can sort all the elements
Pass2: (8,15,20,47), (4,9,30,40), (12,17)
Pass3: (4,8,9,15,20,30,40,47),(12,17)
Pass4: (4,8,9,12,15,17,20,30,40,47)
So within 4 passed we can sort all the elements
8, 9, 15, 20, 47, 4, 12, 17, 30, 40
8, 15, 20, 47, 4, 9, 30, 40, 12, 17
15, 20, 47, 4, 8, 9, 12, 30, 40, 17
4, 8, 9, 15, 20, 47, 12, 17, 30, 40
