SlideShare a Scribd company logo
1 of 10
Quick Sort Demo
Anish
qa.zariga.com
Quick Sort
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
51 41 21 61 81 101 46 71 105 31 91 76
qa.zariga.com
1. Divide and Conquer design.
2. It works recursively
3. Choose a Pivot element in an array
(Random)
P
i
v
o
t
4. Place this element in such a way, the
array list will get divided into two sublist
so that pivot element will be greater than
first sublist and less than other sublist
Quick Sort Scanning from right to left the first
number visited that has value less than 51, thus
exchange both of them
Iteration=1
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
51 41 21 61 81 101 46 71 105 31 91 76
s
t
a
r
t
Left to right search
the number which
less that 51 swap
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 61 81 101 46 71 105 51 91 76qa.zariga.com
Pivot
Element
Quick Sort Scanning from left to right the first
number visited that has value greater than 51, thus
exchange both of them
Iteration=2
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 61 81 101 46 71 105 51 91 76
s
t
a
r
t
Right to left search
51<A[n]
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 51 81 101 46 71 105 61 91 76
qa.zariga.com
Quick Sort Scanning from right to left the first
number visited that has value less than 51, thus
exchange both of them
Iteration=3
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 51 81 101 46 71 105 61 91 76
s
t
a
r
t
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 46 81 101 51 71 105 61 91 76
qa.zariga.com
Quick Sort Scanning from left to right the first
number visited that has value greater than 51, thus
exchange both of them
Iteration=4
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 46 81 101 51 71 105 61 91 76
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 46 51 101 81 71 105 61 91 76
qa.zariga.com
Quick Sort Scanning from right to left the first
number visited that has value less than 51, thus
exchange both of them
Iteration=6A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 46 51 101 81 71 105 61 91 76
s
t
a
r
t
51 >A[n]
No Element Found
Scanning from left to right the first number visited that has value greater than 51,
thus exchange both of them
51<A[n]
No Element Found
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 46 51 101 81 71 105 61 91 76
qa.zariga.com
Quick Sort The Number 51 is Placed
to proper Position
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
31 41 21 46 51 101 81 71 105 61 91 76
Sublist1 has value
less than 51
Sublist1 has value
greater than 51
1. The Whole Process is repeated for
both Sublist1 and Sublis2
2. The Final List what we get as Sorted
List
A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]
21 31 41 46 51 61 71 76 81 91 101 105
qa.zariga.com
Quick Sort Analysis
• Worst Case O(n )
– Pivot is the Smallest or Largest element in Array
• Worst Case O(nlogn )
– Each Array is divided into two equla subarray of
size n/2
2
qa.zariga.com
Thanks
Visit
zariga.com
qa.zariga.com
youtube.com/zarigatongy/
qa.zariga.com

More Related Content

Recently uploaded

ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 

Recently uploaded (20)

ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Quick sort demo

  • 2. Quick Sort A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 51 41 21 61 81 101 46 71 105 31 91 76 qa.zariga.com 1. Divide and Conquer design. 2. It works recursively 3. Choose a Pivot element in an array (Random) P i v o t 4. Place this element in such a way, the array list will get divided into two sublist so that pivot element will be greater than first sublist and less than other sublist
  • 3. Quick Sort Scanning from right to left the first number visited that has value less than 51, thus exchange both of them Iteration=1 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 51 41 21 61 81 101 46 71 105 31 91 76 s t a r t Left to right search the number which less that 51 swap A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 61 81 101 46 71 105 51 91 76qa.zariga.com Pivot Element
  • 4. Quick Sort Scanning from left to right the first number visited that has value greater than 51, thus exchange both of them Iteration=2 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 61 81 101 46 71 105 51 91 76 s t a r t Right to left search 51<A[n] A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 51 81 101 46 71 105 61 91 76 qa.zariga.com
  • 5. Quick Sort Scanning from right to left the first number visited that has value less than 51, thus exchange both of them Iteration=3 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 51 81 101 46 71 105 61 91 76 s t a r t A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 46 81 101 51 71 105 61 91 76 qa.zariga.com
  • 6. Quick Sort Scanning from left to right the first number visited that has value greater than 51, thus exchange both of them Iteration=4 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 46 81 101 51 71 105 61 91 76 A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 46 51 101 81 71 105 61 91 76 qa.zariga.com
  • 7. Quick Sort Scanning from right to left the first number visited that has value less than 51, thus exchange both of them Iteration=6A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 46 51 101 81 71 105 61 91 76 s t a r t 51 >A[n] No Element Found Scanning from left to right the first number visited that has value greater than 51, thus exchange both of them 51<A[n] No Element Found A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 46 51 101 81 71 105 61 91 76 qa.zariga.com
  • 8. Quick Sort The Number 51 is Placed to proper Position A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 31 41 21 46 51 101 81 71 105 61 91 76 Sublist1 has value less than 51 Sublist1 has value greater than 51 1. The Whole Process is repeated for both Sublist1 and Sublis2 2. The Final List what we get as Sorted List A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12] 21 31 41 46 51 61 71 76 81 91 101 105 qa.zariga.com
  • 9. Quick Sort Analysis • Worst Case O(n ) – Pivot is the Smallest or Largest element in Array • Worst Case O(nlogn ) – Each Array is divided into two equla subarray of size n/2 2 qa.zariga.com

Editor's Notes

  1. Scanning from right to left the first number visited that has value less than 51, thus exchange both of them
  2. Scanning from right to left the first number visited that has value less than 51, thus exchange both of them
  3. Scanning from left to right the first number visited that has value greater than 51, thus exchange both of them
  4. Scanning from right to left the first number visited that has value less than 51, thus exchange both of them
  5. Scanning from left to right the first number visited that has value greater than 51, thus exchange both of them
  6. Scanning from right to left the first number visited that has value less than 51, thus exchange both of them