Wednesday, 7 December 2016

Even-Odd Merge Sort



Experiment No. 11
Aim :    To perform Even-Odd Merge Sort on computer cluster
Algorithm:
Begin:
1. Accept the length of the array (in multiples of 2)
2. divide the array into two halves one of even sequence and other of odd sequence(indices)
3. for each sequence use parallel partitions
Do
  Call partition (array,start,end)
End
4. merge two sorted arrays.
          Merge(array1,array2,size)
5. End


Partition()
Begin
mergesort()
end

Merge()
Begin
compare two arrays and merge
End

Theory: 
Initially we accept a single array from the user and then split into two, one of odd sequence and other of even sequence. Then each sequence is sorted in parallel by using merge sort, and then we get two arrays which are sorted. The two arrays are merged and sorted into a single array.
Explain with Example :  

Mathematical Model :

Input :  Numbers to be sorted
Output:  sorted array

No comments:

Post a Comment