SlideShare a Scribd company logo
1 of 10
Download to read offline
Parallel quicksort
Sylwia Dzikiewicz
Marta Leniewska
Mikołaj Olszewski
Marcin Woch
Michał Żelazowski
Sequential quicksort
 Quicksort

(Array, start, end)

If (start < end)
middle = partition (Array, start, end)
quicksort(Array, start, middle)
quicksort(Array, middle+1, end)
Sequential quicksort
 Partition

(Array, start, end)

X = Array [start]
I = start - 1
J = end + 1
while TRUE
repeat J = J –1 until Array [ J ] <= X
repeat I = I +1 until Array [ I ] >=X
if I < J swap (Array [ I ], Array [ J ] )
else return J
Sequential quicksort – complexity
analysis
 Pessimistic
–

O (n2)

 Average
–

complexity

complexity

O (n log n)
Parallel quicksort
P a r a lle l q u ic k s o rt
Q s o rt
Q s o rt
Q s o rt

Q s o rt

Q s o rt

Q s o rt

Q s o rt

Q s o rt

Q s o rt

Q s o rt

Q s o rt
Parallel quicksort


How a single processor makes QuickSort (Array, start,
end)
–
–
–
–
–

J = Partition (Array, start, end)
Start a new thread on another processor : QuickSort(Array,
start, J)
Start a new thread on another processor : QuickSort(Array,
J+1, end)
Wait for both threads to complete
Notice your parent that your task is finished
Parallel quicksort
 OR
–
–
–
–
–

:

J = Partition (Array, start, end)
Start a new thread on another processor :
QuickSort(Array, start, J)
Execute QuickSort(Array, J+1, end)
Wait for the thread to complete
Notice your parent that your task is finished
Parallel quicksort
 In

case no processor can take thread, the
thread is put into a queue for later processing.
 After a processor has done its task, it checks
whether the queue contains any waiting
threads. If so, it removes the first task from the
queue and processes it.
Parallel quicksort
 Methods
–
–
–

of choosing the split key

First element
Average of : first, last and medium element
Median (the median of a sample is expected to be
the median of the whole array)
Parallel quicksort
A

new thread is created only if the length of the
array to sort is no less than MIN_ARRAY_SIZE
constant
 If the length of the array to sort is less than
MIN_QUICKSORT_SIZE, the array is sorted
using a simple algorithm (eg. Insertionsort or
Selectionsort), which require no new threads.
 MIN_QUICKSORT_SIZE <=
MIN_ARRAY_SIZE

More Related Content

What's hot

What's hot (20)

Hash table in data structure and algorithm
Hash table in data structure and algorithmHash table in data structure and algorithm
Hash table in data structure and algorithm
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Big O Notation.ppt
Big O Notation.pptBig O Notation.ppt
Big O Notation.ppt
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)Balanced Tree (AVL Tree & Red-Black Tree)
Balanced Tree (AVL Tree & Red-Black Tree)
 
NoSQL Databases: Why, what and when
NoSQL Databases: Why, what and whenNoSQL Databases: Why, what and when
NoSQL Databases: Why, what and when
 
Heap sort
Heap sortHeap sort
Heap sort
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Linked list
Linked list Linked list
Linked list
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Doubly circular linked list
Doubly circular linked listDoubly circular linked list
Doubly circular linked list
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Merge Sort
Merge SortMerge Sort
Merge Sort
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
PRIM’S AND KRUSKAL’S ALGORITHM
PRIM’S AND KRUSKAL’S  ALGORITHMPRIM’S AND KRUSKAL’S  ALGORITHM
PRIM’S AND KRUSKAL’S ALGORITHM
 
How to make boxed text with LaTeX
How to make boxed text with LaTeXHow to make boxed text with LaTeX
How to make boxed text with LaTeX
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Chap 7 binary threaded tree
Chap 7 binary threaded treeChap 7 binary threaded tree
Chap 7 binary threaded tree
 
AVL Tree Data Structure
AVL Tree Data StructureAVL Tree Data Structure
AVL Tree Data Structure
 

Similar to Parallel quicksort cz. 1

Quick sort by Sania Nisar
Quick sort by Sania NisarQuick sort by Sania Nisar
Quick sort by Sania NisarSania Nisar
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sortingsajinis3
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0BG Java EE Course
 
Class13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfClass13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfAkashSingh625550
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxDeepakM509554
 
Selection sort
Selection sortSelection sort
Selection sortasra khan
 
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...Tosin Amuda
 
Selection sort
Selection sortSelection sort
Selection sortamna izzat
 
Selection sort lab mannual
Selection sort lab mannualSelection sort lab mannual
Selection sort lab mannualmaamir farooq
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"Ra'Fat Al-Msie'deen
 
Chp-1 Quick Review of basic concepts.pdf
Chp-1 Quick Review of basic concepts.pdfChp-1 Quick Review of basic concepts.pdf
Chp-1 Quick Review of basic concepts.pdfSolomonMolla4
 
Sorting Algorithms.
Sorting Algorithms.Sorting Algorithms.
Sorting Algorithms.Saket Kumar
 

Similar to Parallel quicksort cz. 1 (20)

Quick sort by Sania Nisar
Quick sort by Sania NisarQuick sort by Sania Nisar
Quick sort by Sania Nisar
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Sorting pnk
Sorting pnkSorting pnk
Sorting pnk
 
Sorting
SortingSorting
Sorting
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Class13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdfClass13_Quicksort_Algorithm.pdf
Class13_Quicksort_Algorithm.pdf
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptx
 
Selection sort
Selection sortSelection sort
Selection sort
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
An Experiment to Determine and Compare Practical Efficiency of Insertion Sort...
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Selection sort
Selection sortSelection sort
Selection sort
 
simple-sorting algorithms
simple-sorting algorithmssimple-sorting algorithms
simple-sorting algorithms
 
Selection sort
Selection sortSelection sort
Selection sort
 
Selection sort lab mannual
Selection sort lab mannualSelection sort lab mannual
Selection sort lab mannual
 
Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"Algorithms - "Chapter 2 getting started"
Algorithms - "Chapter 2 getting started"
 
Chp-1 Quick Review of basic concepts.pdf
Chp-1 Quick Review of basic concepts.pdfChp-1 Quick Review of basic concepts.pdf
Chp-1 Quick Review of basic concepts.pdf
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Lec 03 - Sorting.pptx
Lec 03 - Sorting.pptxLec 03 - Sorting.pptx
Lec 03 - Sorting.pptx
 
Sorting Algorithms.
Sorting Algorithms.Sorting Algorithms.
Sorting Algorithms.
 

More from Mikołaj Olszewski

The metadata driven e-laboratory web client
The metadata driven e-laboratory web clientThe metadata driven e-laboratory web client
The metadata driven e-laboratory web clientMikołaj Olszewski
 
Optoelektroniczne modelowanie sieci neuronowej cz. 1
Optoelektroniczne modelowanie sieci neuronowej cz. 1Optoelektroniczne modelowanie sieci neuronowej cz. 1
Optoelektroniczne modelowanie sieci neuronowej cz. 1Mikołaj Olszewski
 
Programowanie Komponentowe: #E Podsumowanie
Programowanie Komponentowe: #E PodsumowanieProgramowanie Komponentowe: #E Podsumowanie
Programowanie Komponentowe: #E PodsumowanieMikołaj Olszewski
 
Programowanie Komponentowe: #D Model komponentowy OSGi
Programowanie Komponentowe: #D Model komponentowy OSGiProgramowanie Komponentowe: #D Model komponentowy OSGi
Programowanie Komponentowe: #D Model komponentowy OSGiMikołaj Olszewski
 
Programowanie Komponentowe: #C Wprowadzenie do OSGi
Programowanie Komponentowe: #C Wprowadzenie do OSGiProgramowanie Komponentowe: #C Wprowadzenie do OSGi
Programowanie Komponentowe: #C Wprowadzenie do OSGiMikołaj Olszewski
 
Programowanie Komponentowe: #B Komponentowe aspekty springa
Programowanie Komponentowe: #B Komponentowe aspekty springaProgramowanie Komponentowe: #B Komponentowe aspekty springa
Programowanie Komponentowe: #B Komponentowe aspekty springaMikołaj Olszewski
 
Optoelektroniczne sieci neuronowe
Optoelektroniczne sieci neuronoweOptoelektroniczne sieci neuronowe
Optoelektroniczne sieci neuronoweMikołaj Olszewski
 
Programowanie Komponentowe: #A Wprowadzenie do Springa
Programowanie Komponentowe: #A Wprowadzenie do SpringaProgramowanie Komponentowe: #A Wprowadzenie do Springa
Programowanie Komponentowe: #A Wprowadzenie do SpringaMikołaj Olszewski
 
Programowanie Komponentowe: #9 Java Beans
Programowanie Komponentowe: #9 Java BeansProgramowanie Komponentowe: #9 Java Beans
Programowanie Komponentowe: #9 Java BeansMikołaj Olszewski
 
Optyczne solitony przestrzenne
Optyczne solitony przestrzenneOptyczne solitony przestrzenne
Optyczne solitony przestrzenneMikołaj Olszewski
 
Kwantowe struktury półprzewodnikowe
Kwantowe struktury półprzewodnikoweKwantowe struktury półprzewodnikowe
Kwantowe struktury półprzewodnikoweMikołaj Olszewski
 
Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...
Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...
Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...Mikołaj Olszewski
 
Metody efektywnego łączenia sieci neuronowych
Metody efektywnego łączenia sieci neuronowychMetody efektywnego łączenia sieci neuronowych
Metody efektywnego łączenia sieci neuronowychMikołaj Olszewski
 
Programowanie Komponentowe: #6 Wersjonowanie
Programowanie Komponentowe: #6 WersjonowanieProgramowanie Komponentowe: #6 Wersjonowanie
Programowanie Komponentowe: #6 WersjonowanieMikołaj Olszewski
 

More from Mikołaj Olszewski (20)

Architektura heksagonalna
Architektura heksagonalnaArchitektura heksagonalna
Architektura heksagonalna
 
The metadata driven e-laboratory web client
The metadata driven e-laboratory web clientThe metadata driven e-laboratory web client
The metadata driven e-laboratory web client
 
Optoelektroniczne modelowanie sieci neuronowej cz. 1
Optoelektroniczne modelowanie sieci neuronowej cz. 1Optoelektroniczne modelowanie sieci neuronowej cz. 1
Optoelektroniczne modelowanie sieci neuronowej cz. 1
 
Programowanie Komponentowe: #E Podsumowanie
Programowanie Komponentowe: #E PodsumowanieProgramowanie Komponentowe: #E Podsumowanie
Programowanie Komponentowe: #E Podsumowanie
 
Programowanie Komponentowe: #D Model komponentowy OSGi
Programowanie Komponentowe: #D Model komponentowy OSGiProgramowanie Komponentowe: #D Model komponentowy OSGi
Programowanie Komponentowe: #D Model komponentowy OSGi
 
Programowanie Komponentowe: #C Wprowadzenie do OSGi
Programowanie Komponentowe: #C Wprowadzenie do OSGiProgramowanie Komponentowe: #C Wprowadzenie do OSGi
Programowanie Komponentowe: #C Wprowadzenie do OSGi
 
Programowanie Komponentowe: #B Komponentowe aspekty springa
Programowanie Komponentowe: #B Komponentowe aspekty springaProgramowanie Komponentowe: #B Komponentowe aspekty springa
Programowanie Komponentowe: #B Komponentowe aspekty springa
 
Optoelektroniczne sieci neuronowe
Optoelektroniczne sieci neuronoweOptoelektroniczne sieci neuronowe
Optoelektroniczne sieci neuronowe
 
Programowanie Komponentowe: #A Wprowadzenie do Springa
Programowanie Komponentowe: #A Wprowadzenie do SpringaProgramowanie Komponentowe: #A Wprowadzenie do Springa
Programowanie Komponentowe: #A Wprowadzenie do Springa
 
Materiały fotorefrakcyjne
Materiały fotorefrakcyjneMateriały fotorefrakcyjne
Materiały fotorefrakcyjne
 
Programowanie Komponentowe: #9 Java Beans
Programowanie Komponentowe: #9 Java BeansProgramowanie Komponentowe: #9 Java Beans
Programowanie Komponentowe: #9 Java Beans
 
Lokalne sieci światłowodowe
Lokalne sieci światłowodoweLokalne sieci światłowodowe
Lokalne sieci światłowodowe
 
Optyczne solitony przestrzenne
Optyczne solitony przestrzenneOptyczne solitony przestrzenne
Optyczne solitony przestrzenne
 
Swiatłowodowy czujnik prądu
Swiatłowodowy czujnik prąduSwiatłowodowy czujnik prądu
Swiatłowodowy czujnik prądu
 
Optyka ciekłych kryształów
Optyka ciekłych kryształówOptyka ciekłych kryształów
Optyka ciekłych kryształów
 
Kwantowe struktury półprzewodnikowe
Kwantowe struktury półprzewodnikoweKwantowe struktury półprzewodnikowe
Kwantowe struktury półprzewodnikowe
 
Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...
Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...
Programowanie Komponentowe: #7 Programowanie asynchroniczne i sterowane zdarz...
 
Metody efektywnego łączenia sieci neuronowych
Metody efektywnego łączenia sieci neuronowychMetody efektywnego łączenia sieci neuronowych
Metody efektywnego łączenia sieci neuronowych
 
Parallel quicksort cz. 2
Parallel quicksort cz. 2Parallel quicksort cz. 2
Parallel quicksort cz. 2
 
Programowanie Komponentowe: #6 Wersjonowanie
Programowanie Komponentowe: #6 WersjonowanieProgramowanie Komponentowe: #6 Wersjonowanie
Programowanie Komponentowe: #6 Wersjonowanie
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Parallel quicksort cz. 1

  • 1. Parallel quicksort Sylwia Dzikiewicz Marta Leniewska Mikołaj Olszewski Marcin Woch Michał Żelazowski
  • 2. Sequential quicksort  Quicksort (Array, start, end) If (start < end) middle = partition (Array, start, end) quicksort(Array, start, middle) quicksort(Array, middle+1, end)
  • 3. Sequential quicksort  Partition (Array, start, end) X = Array [start] I = start - 1 J = end + 1 while TRUE repeat J = J –1 until Array [ J ] <= X repeat I = I +1 until Array [ I ] >=X if I < J swap (Array [ I ], Array [ J ] ) else return J
  • 4. Sequential quicksort – complexity analysis  Pessimistic – O (n2)  Average – complexity complexity O (n log n)
  • 5. Parallel quicksort P a r a lle l q u ic k s o rt Q s o rt Q s o rt Q s o rt Q s o rt Q s o rt Q s o rt Q s o rt Q s o rt Q s o rt Q s o rt Q s o rt
  • 6. Parallel quicksort  How a single processor makes QuickSort (Array, start, end) – – – – – J = Partition (Array, start, end) Start a new thread on another processor : QuickSort(Array, start, J) Start a new thread on another processor : QuickSort(Array, J+1, end) Wait for both threads to complete Notice your parent that your task is finished
  • 7. Parallel quicksort  OR – – – – – : J = Partition (Array, start, end) Start a new thread on another processor : QuickSort(Array, start, J) Execute QuickSort(Array, J+1, end) Wait for the thread to complete Notice your parent that your task is finished
  • 8. Parallel quicksort  In case no processor can take thread, the thread is put into a queue for later processing.  After a processor has done its task, it checks whether the queue contains any waiting threads. If so, it removes the first task from the queue and processes it.
  • 9. Parallel quicksort  Methods – – – of choosing the split key First element Average of : first, last and medium element Median (the median of a sample is expected to be the median of the whole array)
  • 10. Parallel quicksort A new thread is created only if the length of the array to sort is no less than MIN_ARRAY_SIZE constant  If the length of the array to sort is less than MIN_QUICKSORT_SIZE, the array is sorted using a simple algorithm (eg. Insertionsort or Selectionsort), which require no new threads.  MIN_QUICKSORT_SIZE <= MIN_ARRAY_SIZE