Using the below algorithm, find the number of comparisons that will be found on
ID: 3693747 • Letter: U
Question
Using the below algorithm, find the number of comparisons that will be found on a list of 50,25, and 12 numbers, and explain why/how you found your answer.
For j = 1 to N/2 do
Parallel Start
For k =1 to N/2 do
Pk compares M2k-1 and M2k
If they are out of order then
Swap them
End if
End for
Parallel End
Parallel Start
For k=1 to N/2-1 do
Pk compares M2k and M2k+1
If they are out of order then
End if
End for
Parallel end
End for
Explanation / Answer
Given algorithm is a odd-even swapping sort algorithm.
The given sorting contains number of processors in half such that moves N/2 times on the elements
(N-1) comparisons forward to the correct possition.
Given list contains 3 elements, 50,25, and 12.
So, the number of comparisons that will be found on a list of 50,25, and 12 numbers are (3-1)=2.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.