SlideShare a Scribd company logo
Parallel sorting Algorithms
By- Garima Shakya
Sorting in Parallel
● Why?
it is a frequent operation in many applications.
● Goal?
sorting a sequence of values in increasing order using n processors
● Potential speedup?
best sequential algorithm has complexity= O(n log n)
● the best we can aim with a parallel algorithm, using n processors is:
optimal complexity of a parallel sorting algorithm: O(n log n)/n = O(log n)
Parallel Sorting
Algorithms
● Parallel Bubble Sort
● Parallel Merge Sort
● Bitonic Sort
● Shear sort
Parallel Sorting
Algorithms
● Parallel Bubble Sort
● Parallel Merge Sort
● Bitonic Sort
● Shear sort
Bubble Sort
● One of the straight-forward sorting methods.
– Cycles through the list.
– Compares consecutive elements and swaps them if necessary.
– Stops when no more out of order pair.
● Slow & inefficient.
● Average performance is O(n^2 ).
Bubble Sort:
Parallel Bubble Sort:
● Also known as Odd-Even Bubble sort.
● operates in two alternate phases:
Phase-even:
even processes exchange values with right neighbors.
Phase-odd:
odd processes exchange values with right neighbors.
Parallel bubble sort:
Parallel Bubble Sort:
Algorithm:
1. For k = 0 to n-1
2. If k is even then
3. for i = 0 to (n/2) do in parallel
4. If A[2i] > A[2i+1] then
5. Exchange A[2i] ↔ A[2i+1]
6. Else
7. for i = 0 to (n/2)-1 do in parallel
8. If A[2i+1] > A[2i+2] then
9. Exchange A[2i+1] ↔ A[2i+2]
10. Next k
Parallel bubble sort : Analysis
● Steps 1-10 is a one big loop that is represented n times.
● Therefore, the parallel time complexity is O(n).
● The algorithm, odd-numbered steps need (n/2) - 1 processors and even-numbered
steps require (n/2) processors.
● Therefore, this needs O(n) processors.
Parallel Sorting
Algorithms
● Parallel Bubble Sort
● Parallel Merge Sort
● Bitonic Sort
● Shear sort
Mergesort:
● Example of a divide-and-conquer algorithm.
● Sorting method to sort a vector; first subdivides it in two parts,
● applies again the same method to each part and when they are both sorted (2 sorted
vectors/lists) with m and n elements,
● They are merged to produce a sorted vector that contains m + n elements of the initial
vector.
● The average complexity is O(n log n).
● T (n) = b n=1
=2T(n/2)+b(n) n>1
● Solve the recurrence relation, T(n) = O(nlogn)
Parallel Merge Sort:
● Collects sorted list onto one processor.
● Merges elements as they come together.
● Simple tree structure.
● Parallelism is limited when near the root.
Divide:
Parallel Merge Sort:
● Collects sorted list onto one processor.
● Merges elements as they come together.
● Simple tree structure.
● Parallelism is limited when near the root.
Conquer
:
Parallel Merge sort: Using a strategy to assign work to
processors organized in a tree.
Merge sort - Time complexity
● Sequential Merge sort, O(nlogn)
● In Parallel,We have n processors
● logn time is required to divide sequence
● logn is for merging it.
● logn+logn= 2 logn
● O(logn)
Parallel Sorting
Algorithms
● Parallel Bubble Sort
● Parallel Merge Sort
● Bitonic Sort
● Shear sort
Bitonic Sort :
● A Bitonic List is defined as a list with
no more than one LOCAL MAXIMUM and no
more than one LOCAL MINIMUM.
● (Endpoints must be considered - wraparound )
A sequence is bitonic if it contains two
sequences, one increasing and one decreasing,
i.e.
● a1
< a2
< . . . < ai−1
< ai
> ai+1
> ai+2
> . . . > an
for
some i such that (0 ≤ i ≤ n)
● a sequence is bitonic if the property described
is attained by a circular rotation to the right of
its elements.
Bitonic sort:
How many parallel steps does it take to sort ?
--> logN
How would you sort a bitonic list WHEN N is NOT A POWER OF 2 ?
-->Use as many processes as N' where N' is a power of 2 and the
smallest number larger than N. Assign a special value such as
"infinity" to all the extra processes (some kind of a padding).
Bitonic Sort:
How to divide a bitonic sequence into two
bitonic subsequences ??
● The compare-and-exchange
operation moves smaller values to
the left and greater values to the
right.
● Given a bitonic sequence, if we apply
recursively these operations we get a
sorted sequence.
Bitonic Sort:
How to divide a bitonic sequence into two
bitonic subsequences ??
● The compare-and-exchange
operation moves smaller values to
the left and greater values to the
right.
● Given a bitonic sequence, if we apply
recursively these operations we get a
sorted sequence.
Number of steps (P=n)
● In order to form a sorted sequence of length n from two sorted sequences of length n/2,
there are log(n) comparator stages required.
● T(n) = log(n) + T(n/2)
● The solution of this recurrence equation is,
● T(n) = log(n) + log(n)-1 + log(n)-2 + ... + 1 = log(n) · (log(n)+1) / 2
● Each stage of the sorting network consists of n/2 comparators. On the whole, these are
Θ(n·log2
(n)) comparators.
● For P=n, T(n)= Θ(n·log2
(n)) / n = Θ(log2
(n))
Bitonic Sort:
How processors
will be connected
at different
stages??
(when N=P).
Parallel Sorting
Algorithms
● Parallel Bubble Sort
● Parallel Merge Sort
● Bitonic Sort
● Shear sort
Two-Dimensional Sorting on a Mesh
● Two network structures have received
special attention:
mesh and hypercube
● The layout of a sorted sequence on a
mesh could be row by row or snake-like:
Shear Sort:
Input: unsorted nn-array.
Output: the array sorted in snake-like order
Method:
repeat log(n) times
i. sort the rows (in alternating direction);
ii. sort the columns;
sort the rows;
Sorting the rows in alternating direction means that even rows are sorted from left to right
and odd rows from right to left.
Shear sort:
Alternate row and column sorting until list is fully sorted.
Alternate row directions to get snake-like sorting:
Shear sort – Time complexity
ODD-PHASE:
Even Rows: sort ascending order (use O-E Transposition sort) O(n)
Odd Rows: sort descending order (use O-E Transposition sort) O(n)
EVEN-PHASE: Sort each column in ascending order.
It takes O(logn) phases to sort (n x n) numbers: T = O(nlogn)
Tpar
= O(logn)
Parallel sorting - summary
Computational time complexity using P=n processors
Parallel bubble sort - O(n)
Parallel merge sort - O(log n)
Bitonic sort - O(log2
n)
Parallel Shear sort - O(logn)
References:
● “Parallel Programming Techniques & Applications Using Networked Workstations &
Parallel Computers, 2nd ed.” B.Wilkinson)
● http://web.mst.edu/~ercal/387/Suppl/class.9.txt
● http://www.gel.usherbrooke.ca/mailhot/gei431/labos/labo2/oets_ss2.html
● http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/twodim/shear/shearsorten.
htm
● https://en.wikipedia.org/wiki/Bitonic_sorter
Thank You!
Ad

More Related Content

What's hot (20)

Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
Vajira Thambawita
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
Jothi Lakshmi
 
Data Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelData Parallel and Object Oriented Model
Data Parallel and Object Oriented Model
Nikhil Sharma
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
 
Parallel computing chapter 3
Parallel computing chapter 3Parallel computing chapter 3
Parallel computing chapter 3
Md. Mahedi Mahfuj
 
B and B+ tree
B and B+ treeB and B+ tree
B and B+ tree
Ashish Arun
 
An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms
Hakky St
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
Rajendran
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
swapnac12
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
Arvind Kumar
 
Introduction to Parallel Computing
Introduction to Parallel ComputingIntroduction to Parallel Computing
Introduction to Parallel Computing
Akhila Prabhakaran
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
Chapter 7: Matrix Multiplication
Chapter 7: Matrix MultiplicationChapter 7: Matrix Multiplication
Chapter 7: Matrix Multiplication
Heman Pathak
 
Three Address code
Three Address code Three Address code
Three Address code
Pooja Dixit
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approach
padmeshagrekar
 
Activation function
Activation functionActivation function
Activation function
Astha Jain
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
Muhammad Amjad Rana
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
Kumar
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
Vajira Thambawita
 
RECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSINGRECURSIVE DESCENT PARSING
RECURSIVE DESCENT PARSING
Jothi Lakshmi
 
Data Parallel and Object Oriented Model
Data Parallel and Object Oriented ModelData Parallel and Object Oriented Model
Data Parallel and Object Oriented Model
Nikhil Sharma
 
Parallel computing chapter 3
Parallel computing chapter 3Parallel computing chapter 3
Parallel computing chapter 3
Md. Mahedi Mahfuj
 
An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms
Hakky St
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
Rajendran
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
swapnac12
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
Arvind Kumar
 
Introduction to Parallel Computing
Introduction to Parallel ComputingIntroduction to Parallel Computing
Introduction to Parallel Computing
Akhila Prabhakaran
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
Chapter 7: Matrix Multiplication
Chapter 7: Matrix MultiplicationChapter 7: Matrix Multiplication
Chapter 7: Matrix Multiplication
Heman Pathak
 
Three Address code
Three Address code Three Address code
Three Address code
Pooja Dixit
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approach
padmeshagrekar
 
Activation function
Activation functionActivation function
Activation function
Astha Jain
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
Kumar
 

Viewers also liked (20)

August 29, Overview over Systems studied in the course
August 29, Overview over Systems studied in the courseAugust 29, Overview over Systems studied in the course
August 29, Overview over Systems studied in the course
University of Colorado at Boulder
 
Sensors update
Sensors updateSensors update
Sensors update
isutp2
 
Transducer main
Transducer mainTransducer main
Transducer main
Shailendra Gautam
 
Transducer
TransducerTransducer
Transducer
Narendra Kumar Jangid
 
Ai class
Ai classAi class
Ai class
meshaye
 
active and passive sensors
active and passive sensorsactive and passive sensors
active and passive sensors
PRAMODA G
 
Parallel sorting
Parallel sortingParallel sorting
Parallel sorting
Mr. Vikram Singh Slathia
 
Difference between Sensor & Transducer
Difference between Sensor & TransducerDifference between Sensor & Transducer
Difference between Sensor & Transducer
Ahmad Sakib
 
Open-World Mission Specification for Reactive Robots - ICRA 2014
Open-World Mission Specification for Reactive Robots - ICRA 2014Open-World Mission Specification for Reactive Robots - ICRA 2014
Open-World Mission Specification for Reactive Robots - ICRA 2014
Spyros Maniatopoulos
 
Ajm unit 2
Ajm unit 2Ajm unit 2
Ajm unit 2
Elangovan Sivaprakasam
 
Multisensor Data Fusion : Techno Briefing
Multisensor Data Fusion : Techno BriefingMultisensor Data Fusion : Techno Briefing
Multisensor Data Fusion : Techno Briefing
Paveen Juntama
 
Robotics
RoboticsRobotics
Robotics
A Tê Hát
 
Introduction to robotics
Introduction to roboticsIntroduction to robotics
Introduction to robotics
Pantech ProLabs India Pvt Ltd
 
sensors in robotics
sensors in roboticssensors in robotics
sensors in robotics
Omkar Lokhande
 
Passive infrared based human detection alive robot
Passive infrared based human detection alive robotPassive infrared based human detection alive robot
Passive infrared based human detection alive robot
Sidharth Mohapatra
 
Sensors
SensorsSensors
Sensors
Vivek Bapu
 
August 31, Reactive Algorithms I
August 31, Reactive Algorithms IAugust 31, Reactive Algorithms I
August 31, Reactive Algorithms I
University of Colorado at Boulder
 
Application of image processing
Application of image processingApplication of image processing
Application of image processing
University of Potsdam
 
Data acquisition softwares
Data acquisition softwaresData acquisition softwares
Data acquisition softwares
Sachithra Gayan
 
Building Robots Tutorial
Building Robots TutorialBuilding Robots Tutorial
Building Robots Tutorial
Pantech ProLabs India Pvt Ltd
 
Ad

Similar to Parallel sorting Algorithms (20)

Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Syed Zaid Irshad
 
Chap9 slides
Chap9 slidesChap9 slides
Chap9 slides
BaliThorat1
 
Analysis and design of algorithms part2
Analysis and design of algorithms part2Analysis and design of algorithms part2
Analysis and design of algorithms part2
Deepak John
 
Merge sort
Merge sortMerge sort
Merge sort
International Islamic University
 
Lecture23
Lecture23Lecture23
Lecture23
Dr Sandeep Kumar Poonia
 
Selection sort lab mannual
Selection sort lab mannualSelection sort lab mannual
Selection sort lab mannual
maamir farooq
 
Sorting algorithms bubble sort to merge sort.pdf
Sorting  algorithms bubble sort to merge sort.pdfSorting  algorithms bubble sort to merge sort.pdf
Sorting algorithms bubble sort to merge sort.pdf
AyeshaMazhar21
 
Sorting
SortingSorting
Sorting
Gopi Saiteja
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
Cs1311lecture23wdl
Cs1311lecture23wdlCs1311lecture23wdl
Cs1311lecture23wdl
Muhammad Wasif
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Maher Alshammari
 
Module 2_ Divide and Conquer Approach.pptx
Module 2_ Divide and Conquer Approach.pptxModule 2_ Divide and Conquer Approach.pptx
Module 2_ Divide and Conquer Approach.pptx
nikshaikh786
 
Ada notes
Ada notesAda notes
Ada notes
VIKAS SINGH BHADOURIA
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
B.Kirron Reddi
 
Cis435 week06
Cis435 week06Cis435 week06
Cis435 week06
ashish bansal
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
Dr Sandeep Kumar Poonia
 
Sorting
SortingSorting
Sorting
BHARATH KUMAR
 
sorting
sortingsorting
sorting
Ravirajsinh Chauhan
 
03_sorting123456789454545454545444543.ppt
03_sorting123456789454545454545444543.ppt03_sorting123456789454545454545444543.ppt
03_sorting123456789454545454545444543.ppt
ssuser7b9bda1
 
03_sorting and it's types with example .ppt
03_sorting and it's types with example .ppt03_sorting and it's types with example .ppt
03_sorting and it's types with example .ppt
vanshii9976
 
Ad

Recently uploaded (20)

chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
Ch3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendencyCh3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendency
ayeleasefa2
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
定制学历(美国Purdue毕业证)普渡大学电子版毕业证
定制学历(美国Purdue毕业证)普渡大学电子版毕业证定制学历(美国Purdue毕业证)普渡大学电子版毕业证
定制学历(美国Purdue毕业证)普渡大学电子版毕业证
Taqyea
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptxISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
pankaj6188303
 
Geometry maths presentation for begginers
Geometry maths presentation for begginersGeometry maths presentation for begginers
Geometry maths presentation for begginers
zrjacob283
 
Minions Want to eat presentacion muy linda
Minions Want to eat presentacion muy lindaMinions Want to eat presentacion muy linda
Minions Want to eat presentacion muy linda
CarlaAndradesSoler1
 
Customer Segmentation using K-Means clustering
Customer Segmentation using K-Means clusteringCustomer Segmentation using K-Means clustering
Customer Segmentation using K-Means clustering
Ingrid Nyakerario
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdfIAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
mcgardenlevi9
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docxMASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
santosh162
 
Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...
Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...
Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...
Abodahab
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Process Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial IndustryProcess Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial Industry
Process mining Evangelist
 
Deloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining ProjectsDeloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining Projects
Process mining Evangelist
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
Ch3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendencyCh3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendency
ayeleasefa2
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
定制学历(美国Purdue毕业证)普渡大学电子版毕业证
定制学历(美国Purdue毕业证)普渡大学电子版毕业证定制学历(美国Purdue毕业证)普渡大学电子版毕业证
定制学历(美国Purdue毕业证)普渡大学电子版毕业证
Taqyea
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptxISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
ISO 9001_2015 FINALaaaaaaaaaaaaaaaa - MDX - Copy.pptx
pankaj6188303
 
Geometry maths presentation for begginers
Geometry maths presentation for begginersGeometry maths presentation for begginers
Geometry maths presentation for begginers
zrjacob283
 
Minions Want to eat presentacion muy linda
Minions Want to eat presentacion muy lindaMinions Want to eat presentacion muy linda
Minions Want to eat presentacion muy linda
CarlaAndradesSoler1
 
Customer Segmentation using K-Means clustering
Customer Segmentation using K-Means clusteringCustomer Segmentation using K-Means clustering
Customer Segmentation using K-Means clustering
Ingrid Nyakerario
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdfIAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
mcgardenlevi9
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docxMASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
santosh162
 
Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...
Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...
Day 1 - Lab 1 Reconnaissance Scanning with NMAP, Vulnerability Assessment wit...
Abodahab
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Process Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial IndustryProcess Mining and Data Science in the Financial Industry
Process Mining and Data Science in the Financial Industry
Process mining Evangelist
 
Deloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining ProjectsDeloitte - A Framework for Process Mining Projects
Deloitte - A Framework for Process Mining Projects
Process mining Evangelist
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 

Parallel sorting Algorithms

  • 2. Sorting in Parallel ● Why? it is a frequent operation in many applications. ● Goal? sorting a sequence of values in increasing order using n processors ● Potential speedup? best sequential algorithm has complexity= O(n log n) ● the best we can aim with a parallel algorithm, using n processors is: optimal complexity of a parallel sorting algorithm: O(n log n)/n = O(log n)
  • 3. Parallel Sorting Algorithms ● Parallel Bubble Sort ● Parallel Merge Sort ● Bitonic Sort ● Shear sort
  • 4. Parallel Sorting Algorithms ● Parallel Bubble Sort ● Parallel Merge Sort ● Bitonic Sort ● Shear sort
  • 5. Bubble Sort ● One of the straight-forward sorting methods. – Cycles through the list. – Compares consecutive elements and swaps them if necessary. – Stops when no more out of order pair. ● Slow & inefficient. ● Average performance is O(n^2 ).
  • 7. Parallel Bubble Sort: ● Also known as Odd-Even Bubble sort. ● operates in two alternate phases: Phase-even: even processes exchange values with right neighbors. Phase-odd: odd processes exchange values with right neighbors.
  • 9. Parallel Bubble Sort: Algorithm: 1. For k = 0 to n-1 2. If k is even then 3. for i = 0 to (n/2) do in parallel 4. If A[2i] > A[2i+1] then 5. Exchange A[2i] ↔ A[2i+1] 6. Else 7. for i = 0 to (n/2)-1 do in parallel 8. If A[2i+1] > A[2i+2] then 9. Exchange A[2i+1] ↔ A[2i+2] 10. Next k
  • 10. Parallel bubble sort : Analysis ● Steps 1-10 is a one big loop that is represented n times. ● Therefore, the parallel time complexity is O(n). ● The algorithm, odd-numbered steps need (n/2) - 1 processors and even-numbered steps require (n/2) processors. ● Therefore, this needs O(n) processors.
  • 11. Parallel Sorting Algorithms ● Parallel Bubble Sort ● Parallel Merge Sort ● Bitonic Sort ● Shear sort
  • 12. Mergesort: ● Example of a divide-and-conquer algorithm. ● Sorting method to sort a vector; first subdivides it in two parts, ● applies again the same method to each part and when they are both sorted (2 sorted vectors/lists) with m and n elements, ● They are merged to produce a sorted vector that contains m + n elements of the initial vector. ● The average complexity is O(n log n). ● T (n) = b n=1 =2T(n/2)+b(n) n>1 ● Solve the recurrence relation, T(n) = O(nlogn)
  • 13. Parallel Merge Sort: ● Collects sorted list onto one processor. ● Merges elements as they come together. ● Simple tree structure. ● Parallelism is limited when near the root. Divide:
  • 14. Parallel Merge Sort: ● Collects sorted list onto one processor. ● Merges elements as they come together. ● Simple tree structure. ● Parallelism is limited when near the root. Conquer :
  • 15. Parallel Merge sort: Using a strategy to assign work to processors organized in a tree.
  • 16. Merge sort - Time complexity ● Sequential Merge sort, O(nlogn) ● In Parallel,We have n processors ● logn time is required to divide sequence ● logn is for merging it. ● logn+logn= 2 logn ● O(logn)
  • 17. Parallel Sorting Algorithms ● Parallel Bubble Sort ● Parallel Merge Sort ● Bitonic Sort ● Shear sort
  • 18. Bitonic Sort : ● A Bitonic List is defined as a list with no more than one LOCAL MAXIMUM and no more than one LOCAL MINIMUM. ● (Endpoints must be considered - wraparound ) A sequence is bitonic if it contains two sequences, one increasing and one decreasing, i.e. ● a1 < a2 < . . . < ai−1 < ai > ai+1 > ai+2 > . . . > an for some i such that (0 ≤ i ≤ n) ● a sequence is bitonic if the property described is attained by a circular rotation to the right of its elements.
  • 19. Bitonic sort: How many parallel steps does it take to sort ? --> logN How would you sort a bitonic list WHEN N is NOT A POWER OF 2 ? -->Use as many processes as N' where N' is a power of 2 and the smallest number larger than N. Assign a special value such as "infinity" to all the extra processes (some kind of a padding).
  • 20. Bitonic Sort: How to divide a bitonic sequence into two bitonic subsequences ?? ● The compare-and-exchange operation moves smaller values to the left and greater values to the right. ● Given a bitonic sequence, if we apply recursively these operations we get a sorted sequence.
  • 21. Bitonic Sort: How to divide a bitonic sequence into two bitonic subsequences ?? ● The compare-and-exchange operation moves smaller values to the left and greater values to the right. ● Given a bitonic sequence, if we apply recursively these operations we get a sorted sequence.
  • 22. Number of steps (P=n) ● In order to form a sorted sequence of length n from two sorted sequences of length n/2, there are log(n) comparator stages required. ● T(n) = log(n) + T(n/2) ● The solution of this recurrence equation is, ● T(n) = log(n) + log(n)-1 + log(n)-2 + ... + 1 = log(n) · (log(n)+1) / 2 ● Each stage of the sorting network consists of n/2 comparators. On the whole, these are Θ(n·log2 (n)) comparators. ● For P=n, T(n)= Θ(n·log2 (n)) / n = Θ(log2 (n))
  • 23. Bitonic Sort: How processors will be connected at different stages?? (when N=P).
  • 24. Parallel Sorting Algorithms ● Parallel Bubble Sort ● Parallel Merge Sort ● Bitonic Sort ● Shear sort
  • 25. Two-Dimensional Sorting on a Mesh ● Two network structures have received special attention: mesh and hypercube ● The layout of a sorted sequence on a mesh could be row by row or snake-like:
  • 26. Shear Sort: Input: unsorted nn-array. Output: the array sorted in snake-like order Method: repeat log(n) times i. sort the rows (in alternating direction); ii. sort the columns; sort the rows; Sorting the rows in alternating direction means that even rows are sorted from left to right and odd rows from right to left.
  • 27. Shear sort: Alternate row and column sorting until list is fully sorted. Alternate row directions to get snake-like sorting:
  • 28. Shear sort – Time complexity ODD-PHASE: Even Rows: sort ascending order (use O-E Transposition sort) O(n) Odd Rows: sort descending order (use O-E Transposition sort) O(n) EVEN-PHASE: Sort each column in ascending order. It takes O(logn) phases to sort (n x n) numbers: T = O(nlogn) Tpar = O(logn)
  • 29. Parallel sorting - summary Computational time complexity using P=n processors Parallel bubble sort - O(n) Parallel merge sort - O(log n) Bitonic sort - O(log2 n) Parallel Shear sort - O(logn)
  • 30. References: ● “Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers, 2nd ed.” B.Wilkinson) ● http://web.mst.edu/~ercal/387/Suppl/class.9.txt ● http://www.gel.usherbrooke.ca/mailhot/gei431/labos/labo2/oets_ss2.html ● http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/twodim/shear/shearsorten. htm ● https://en.wikipedia.org/wiki/Bitonic_sorter