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

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 

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