0% found this document useful (0 votes)
67 views23 pages

Sorting Algos in Parallel System

This document discusses parallel sorting algorithms and their implementation on parallel systems. It describes odd-even transposition sort and how it can be parallelized by having each processor locally sort its portion of the data and then performing exchange phases in parallel. Quicksort is also covered, explaining how the recursive divide and conquer nature maps well to a parallel binary tree execution where processors work independently at each level until reaching serial base cases. The benefits and limitations of parallelizing sorting algorithms are presented.

Uploaded by

champdarklord
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views23 pages

Sorting Algos in Parallel System

This document discusses parallel sorting algorithms and their implementation on parallel systems. It describes odd-even transposition sort and how it can be parallelized by having each processor locally sort its portion of the data and then performing exchange phases in parallel. Quicksort is also covered, explaining how the recursive divide and conquer nature maps well to a parallel binary tree execution where processors work independently at each level until reaching serial base cases. The benefits and limitations of parallelizing sorting algorithms are presented.

Uploaded by

champdarklord
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Sorting Algorithms in

Parallel Systems
Parallel Systems

 Parallel Processing is information processing that


emphasizes the concurrent manipulation of data
elements belonging to one or more processes
solving a single problem.

 A parallel computer is a multiple processor


computer capable of parallel processing.

 It increases speed of execution.


Odd-Even (Transposition) Sort

• It’s a variant of bubble sort.

• The algo performs N/2 iterations

• It has 2 phases :

 Even-odd exchange

 Odd even exchange


Odd-Even Algo
Odd-Even
Odd-Even Transposition

•After n phases of odd-even exchanges, the sequence


is sorted.

•Each phase of the algorithm (either odd or even)


requires Θ(n) comparisons.

•Serial complexity is Θ(n2).


Parallel Odd-Even Transposition
Parallel odd even transposition

9
Parallel odd even transposition
 P0 P1 P2 P3
 13 7 12 8 5 4 6 1 3 9 2 10

Local sort
 7 12 13 4 5 8 1 3 6 2 9 10
O-E

 4 5 7 8 12 13 1 2 3 6 9 10
E-O

 4 5 7 1 2 3 8 12 13 6 9 10
O-E

 1 2 3 4 5 7 6 8 9 10 12 13
E-O

SORTED: 1 2 3 4 5 6 7 8 9 10 12 13

9
Properties
• The parallel run time of the formulation is

• The efficiency is :

E=1 / [1 – o( ( log p ) / ( log n ) ) + o(p / log n ) ]

• The parallel formulation is cost-optimal for p = O(log


n).
• The isoefficiency function of this parallel formulation
is Θ(p2p).
Quick Sort
Quick sort is one of the most common sorting
algorithms because of its simplicity, low overhead, and
optimal average complexity.

Quick sort selects one of the entries in the sequence to


be the pivot and divides the sequence into two - one
with all elements less than the pivot and other greater.

The process is recursively applied to each of the sub


lists.
Quick Sort
Quick Sort

Example of quick sort algorithm sorting a


sequence of size n = 8.
Parallelizing Quick Sort

•Executing a quick sort can be visualized by constructing a


binary tree.
•We select a pivot. Partition the array into 2 parts:
a) Left ( Smaller ) .
b) Right ( Larger).

•The formulation does not rearrange the elements .


•All the processes can read the pivot in const time .Hence
know which sub-array( smaller or larger) is assigned to it
and proceed to next iteration.
Parallelizing Quick Sort

• A binary tree generated by the


execution of the quick sort
algorithm.

• Each level of the tree


represents a different array-
partitioning iteration.

• If pivot selection is optimal,


then the height of the tree is
Θ(log n), which is also the
number of iterations.
Parallelizing Quick Sort

• Consider a list of size n equally divided across p


processors.
• A pivot is selected by one of the processors and made
known to all processors.
• Each processor partitions its list into two sub array, say
Li and Ui , based on the selected pivot.

• All of the Li lists are merged and all of the Ui lists are
merged separately.
Parallelizing Quick Sort

• The set of processors is partitioned into two


(in proportion of the size of lists L and U). The
process is recursively applied to each of the
lists.
• The recursion ends when a particular sub-
block of element is assigned to a single
process.
• The processor than sorts than sorts the
elements using a serial quick sort algo.
Parallelizing Quick Sort
Parallelizing Quick Sort
Parallelizing Quick Sort
Therefore, the total parallel time is:

The corresponding isoefficiency is Θ(plog2p) due to broadcast and


scan operations.
Limitations

• We need to improve our existing algorithms to


be compatible with parallel systems.

• The initial installation cost of these systems


are quite high.

• We need to ensure continuous communication


( message passing )between these parallel
systems.
Conclusion

• In every real time systems we need to have


sorting.

• Sorted data is always easy to manipulate


than random data.
Thank you

You might also like