Q2 Related with java Manually run the merge sort algorithm o
Q2- Related with java
Manually run the merge sort algorithm on the array {100, 10, 90, 20, 80, 30, 70, 40, 60, 50}.Solution
100 10 90 20 80 30 70 40 60 50
1) First merge sort divides the array in two halves
100 10 90 20 80 30 70 40 60 50
And keep on dividing until we reach atomic value
100 10 90 20 80 30 70 40 60 50
100 10 90 20 80 30 70 40 60 50
100 10 90 20 80 30 70 40 60 50
Now compare the elements in each lst
compare 100 and 10 which ever is larger put that first
1) 10 100
2) 90
3) 20 ad 80 - sorted
4) 30 and 70 -sorted
5) 40, 60 50- after comaprision - 40 50 60
6) Now compare 2& 3 - 90 20 80 - after sorting 20,80,90
7) Now compare 1& array we got in 6 , 10,100 , 20,80 90, after comparision we get 10, 20,80,90,100
8) Compare 4&5 30,70 40 ,50,60 - after sorting 30,40,50,60,70
Now compare 7 and 8
10,20,80,90,1000 30,40,50,60,70
10,20,30,40,50,60,70,80,90,100
