SlideShare a Scribd company logo
QUICK SORT
This sorting algorithm uses the idea of divide and
conquer.
It finds the element called pivot which divides
the array into two halves in such a way that
elements in the left half are smaller than pivot
and elements in the right half are greater than
pivot.
QUICK SORT
Three steps
Find pivot that divides the array into two halves.
Quick sort the left half.
Quick sort the right half.
QUICK SORT
Example
Consider an array having 6 elements
5 2 6 1 3 4
Arrange the elements in ascending order using
quick sort algorithm
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
Left
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
Left
Initially pointing to the
First element of the array
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
Left
Initially pointing to the
First element of the array
Right
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
Left
Initially pointing to the
First element of the array
Right
Initially pointing to the
Last element of the array
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
Left
Initially pointing to the
First element of the array
Right
Initially pointing to the
Last element of the array
Pivot
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
Left
Initially pointing to the
First element of the array
Right
Initially pointing to the
Last element of the array
Pivot
Initially pointing to the
First element
0 1 2 3 4 5
5 2 6 1 3 4
Array index
Array element
This is our unsorted array
Left
Initially pointing to the
First element of the array
Right
Initially pointing to the
Last element of the array
Pivot
Initially pointing to the
First element
We will quick sort this array
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Remember this rule:
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Remember this rule:
All element to the RIGHT of pivot be GREATER than pivot.
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Remember this rule:
All element to the RIGHT of pivot be GREATER than pivot.
All element to the LEFT of pivot be SMALLER than pivot.
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
As the pivot
is pointing at
left
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
As the pivot
is pointing at
left
So we will start
from right
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
As the pivot
is pointing at
left
So we will start
from rightAnd move towards left
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Pivot = 5
Right =4
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Pivot = 5
Right =4
Is Pivot < Right
( 5 < 4)
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Pivot = 5
Right =4
NO
Is Pivot < Right
( 5 < 4)
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Pivot = 5
Right =4
So we swap pivot and right
NO
Is Pivot < Right
( 5 < 4)
0 1 2 3 4 5
5 2 6 1 3 4
Left Right
Pivot
Pivot = 5
Right =4
So we swap pivot and right
NO
Is Pivot < Right
( 5 < 4)
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Right =4
So we swap pivot and right
NO
Is Pivot < Right
( 5 < 4)
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =4
Is Pivot < Left
Now move pivot to right
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =4
Is Pivot < Left
NO
So we swap pivot to the right
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Now the pivot
is pointing at
right
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Now the pivot
is pointing at
right
So we will start
from left
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Now the pivot
is pointing at
right
So we will start
from left
And move towards right
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =4
Is Pivot > Left
( 5 > 4)
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =4
Is Pivot > Left
YES
( 5 > 4)
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =4
Is Pivot > Left
YES
( 5 > 4)
So we move left one position
towards right
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =2
Is Pivot > Left
( 5 > 2)
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =2
Is Pivot > Left
( 5 > 2)
YES
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =2
Is Pivot > Left
( 5 > 2)
YES
So we move left one position
towards right
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =6
Is Pivot > Left
( 5 > 6)
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =6
Is Pivot > Left
( 5 > 6)
NO
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =6
Is Pivot > Left
( 5 > 6)
NO
So we swap pivot and left
0 1 2 3 4 5
4 2 6 1 3 5
Left Right
Pivot
Pivot = 5
Left =6
Is Pivot > Left
( 5 > 6)
NO
So we swap pivot and left
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Left =6
Is Pivot > Left
( 5 > 6)
NO
So we swap pivot and left
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Left =6
Is Pivot > Left
( 5 > 6)
NO
So we swap pivot and left
And move the pivot to left
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Now the pivot is
pointing at left
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Now the pivot is
pointing at left So we will start
from right
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Now the pivot is
pointing at left So we will start
from right
And move towards left
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Right =6
Is Pivot < Right
( 5 < 6)
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Right =6
Is Pivot < Right
( 5 < 6)
YES
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Right =6
Is Pivot < Right
( 5 < 6)
YES
So we move right one position
towards left
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Right =3
Is Pivot < Right
( 5 < 3)
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Right =3
Is Pivot < Right
( 5 < 3)
NO
0 1 2 3 4 5
4 2 5 1 3 6
Left Right
Pivot
Pivot = 5
Right =3
Is Pivot < Right
( 5 < 3)
NO
So we swap pivot and right
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Pivot = 5
Right =3
Is Pivot < Right
( 5 < 3)
NO
So we swap pivot and right
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Pivot = 5
Right =3
Is Pivot > Right
( 5 > 3)
NO
So we swap pivot and right
And move the pivot to right
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Pivot = 5
Left =3
Is Pivot > Left
( 5 > 3)
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Pivot = 5
Left =3YES
Is Pivot > Left
( 5 > 3)
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Pivot = 5
Left =3
Is Pivot > Left
( 5 > 3)
So we move left one position
towards right
YES
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Pivot = 5
Left = 1
Is Pivot > Left
( 5 > 1)
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Now both left and right are pointing at the same element of the array
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Now both left and right are pointing at the same element of the array
This time 5 is the pivot and it is at the
sorted position
4
5
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Now both left and right are pointing at the same element of the array
This time 5 is the pivot and it is at the
sorted position
4
5
Elements left of pivot are smaller
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Now both left and right are pointing at the same element of the array
This time 5 is the pivot and it is at the
sorted position
4
5
Elements left of pivot are smaller
Elements right of
pivot are greater
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Now both left and right are pointing at the same element of the array
This time 5 is the pivot and it is at the
sorted position
4
5
Elements left of pivot are smaller
Elements right of
pivot are greater
So pivot has divided the array into
two sub array
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Now both left and right are pointing at the same element of the array
This time 5 is the pivot and it is at the
sorted position
4
5
Elements left of pivot are smaller
Elements right of
pivot are greater
Left sub array Right sub array
So pivot has divided the array into
two sub array
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Now both left and right are pointing at the same element of the array
This time 5 is the pivot and it is at the
sorted position
4
5
Elements left of pivot are smaller
Elements right of
pivot are greater
Left sub array Right sub array
So pivot has divided the array into
two sub array We will now quick sort
the left sub array
0 1 2 3 4 5
4 2 3 1 5 6
Left Right
Pivot
Pivot = 4
Left =1
Is Pivot < Left
( 4 < 1)
0 1 2 3 4 5
4 2 3 1 5 6
Pivot
Pivot = 4
Left =1
Is Pivot < Left
( 4 < 1)
NO
Left Right
0 1 2 3 4 5
4 2 3 1 5 6
Pivot
Pivot = 4
Left =1
Is Pivot < Left
( 4 < 1)
NO
So we swap pivot and right
Left Right
0 1 2 3 4 5
1 2 3 4 5 6
Pivot
Pivot = 4
Left =1
Is Pivot < Left
( 4 < 1)
NO
So we swap pivot and right
Left Right
0 1 2 3 4 5
1 2 3 4 5 6
Left Right
Pivot
Pivot = 4
Left =1
Is Pivot < Left
( 4 < 1)
NO
So we swap pivot and right
Now move the pivot to right
0 1 2 3 4 5
1 2 3 4 5 6
Pivot
Pivot = 4
Left =1
Is Pivot < Left
( 4 < 1)
NO
So we swap pivot and right
Left Right
0 1 2 3 4 5
1 2 3 4 5 6
The Array is Sorted
Jeanie Lyn Arnoco

More Related Content

What's hot

Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structureSajid Marwat
 
Quick sort
Quick sortQuick sort
Quick sort
Dhruv Sabalpara
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
Shubham Dwivedi
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
Hashing
HashingHashing
Hashing
Amar Jukuntla
 
Insertion sort
Insertion sortInsertion sort
Insertion sortMYER301
 
Sorting
SortingSorting
AVL Tree in Data Structure
AVL Tree in Data Structure AVL Tree in Data Structure
AVL Tree in Data Structure
Vrushali Dhanokar
 
Arrays
ArraysArrays
Digital Search Tree
Digital Search TreeDigital Search Tree
Digital Search Tree
East West University
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Dharita Chokshi
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
ShahDhruv21
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
Zia Ush Shamszaman
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Selection sort
Selection sortSelection sort
Selection sort
stella D
 
Quick sort
Quick sortQuick sort
Quick sort
Jehat Hassan
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Poojith Chowdhary
 

What's hot (20)

Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
Quick sort
Quick sortQuick sort
Quick sort
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Hashing
HashingHashing
Hashing
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Sorting
SortingSorting
Sorting
 
AVL Tree in Data Structure
AVL Tree in Data Structure AVL Tree in Data Structure
AVL Tree in Data Structure
 
Arrays
ArraysArrays
Arrays
 
Digital Search Tree
Digital Search TreeDigital Search Tree
Digital Search Tree
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
 
Selection sort
Selection sortSelection sort
Selection sort
 
Heaps & priority queues
Heaps & priority queuesHeaps & priority queues
Heaps & priority queues
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Selection sort
Selection sortSelection sort
Selection sort
 
Quick sort
Quick sortQuick sort
Quick sort
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 

Viewers also liked

Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
Tareq Hasan
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
 
Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
irdginfo
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
Shakila Mahjabin
 
Philip Crosby Principles
Philip Crosby PrinciplesPhilip Crosby Principles
Philip Crosby Principles
Jeanie Arnoco
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
Jeanie Arnoco
 
Quick sort
Quick sortQuick sort
Quick sort
Rajendran
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questions
Arun Banotra
 
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
 
Java Sorting Algorithms
Java Sorting AlgorithmsJava Sorting Algorithms
Java Sorting Algorithms
Brendan Campbell
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
Rajendran
 
Meaghan technology report
Meaghan technology reportMeaghan technology report
Meaghan technology report
Marq2014
 
Wie zit er écht achter de site mvslim.com?
Wie zit er écht achter de site mvslim.com?Wie zit er écht achter de site mvslim.com?
Wie zit er écht achter de site mvslim.com?
Thierry Debels
 
Access may newsletter
Access may newsletterAccess may newsletter
Access may newsletter
enrique santoyo quezada
 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Sunil Kumar Gunasekaran
 

Viewers also liked (20)

Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
 
Philip Crosby Principles
Philip Crosby PrinciplesPhilip Crosby Principles
Philip Crosby Principles
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
 
Quick sort
Quick sortQuick sort
Quick sort
 
Sorting algos
Sorting algosSorting algos
Sorting algos
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questions
 
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...
 
Java Sorting Algorithms
Java Sorting AlgorithmsJava Sorting Algorithms
Java Sorting Algorithms
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
 
Meaghan technology report
Meaghan technology reportMeaghan technology report
Meaghan technology report
 
Wie zit er écht achter de site mvslim.com?
Wie zit er écht achter de site mvslim.com?Wie zit er écht achter de site mvslim.com?
Wie zit er écht achter de site mvslim.com?
 
Zakon.bih
Zakon.bihZakon.bih
Zakon.bih
 
Access may newsletter
Access may newsletterAccess may newsletter
Access may newsletter
 
The Dream Act
The Dream ActThe Dream Act
The Dream Act
 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
 

More from Jeanie Arnoco

The Database Environment Chapter 15
The Database Environment Chapter 15The Database Environment Chapter 15
The Database Environment Chapter 15
Jeanie Arnoco
 
The Database Environment Chapter 14
The Database Environment Chapter 14The Database Environment Chapter 14
The Database Environment Chapter 14
Jeanie Arnoco
 
The Database Environment Chapter 13
The Database Environment Chapter 13The Database Environment Chapter 13
The Database Environment Chapter 13
Jeanie Arnoco
 
The Database Environment Chapter 12
The Database Environment Chapter 12The Database Environment Chapter 12
The Database Environment Chapter 12
Jeanie Arnoco
 
The Database Environment Chapter 11
The Database Environment Chapter 11The Database Environment Chapter 11
The Database Environment Chapter 11
Jeanie Arnoco
 
The Database Environment Chapter 10
The Database Environment Chapter 10The Database Environment Chapter 10
The Database Environment Chapter 10
Jeanie Arnoco
 
The Database Environment Chapter 9
The Database Environment Chapter 9The Database Environment Chapter 9
The Database Environment Chapter 9
Jeanie Arnoco
 
The Database Environment Chapter 8
The Database Environment Chapter 8The Database Environment Chapter 8
The Database Environment Chapter 8
Jeanie Arnoco
 
The Database Environment Chapter 7
The Database Environment Chapter 7The Database Environment Chapter 7
The Database Environment Chapter 7
Jeanie Arnoco
 
The Database Environment Chapter 6
The Database Environment Chapter 6The Database Environment Chapter 6
The Database Environment Chapter 6
Jeanie Arnoco
 
The Database Environment Chapter 5
The Database Environment Chapter 5The Database Environment Chapter 5
The Database Environment Chapter 5
Jeanie Arnoco
 
The Database Environment Chapter 4
The Database Environment Chapter 4The Database Environment Chapter 4
The Database Environment Chapter 4
Jeanie Arnoco
 
The Database Environment Chapter 3
The Database Environment Chapter 3The Database Environment Chapter 3
The Database Environment Chapter 3
Jeanie Arnoco
 
The Database Environment Chapter 2
The Database Environment Chapter 2The Database Environment Chapter 2
The Database Environment Chapter 2
Jeanie Arnoco
 
The Database Environment Chapter 1
The Database Environment Chapter 1The Database Environment Chapter 1
The Database Environment Chapter 1
Jeanie Arnoco
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAP
Jeanie Arnoco
 
Hacking and Online Security
Hacking and Online SecurityHacking and Online Security
Hacking and Online Security
Jeanie Arnoco
 
(CAR)Cordillera Administrative Region
(CAR)Cordillera Administrative Region (CAR)Cordillera Administrative Region
(CAR)Cordillera Administrative Region
Jeanie Arnoco
 
Quality Gurus Student
Quality Gurus StudentQuality Gurus Student
Quality Gurus Student
Jeanie Arnoco
 
QUALITY STANDARDS
QUALITY STANDARDSQUALITY STANDARDS
QUALITY STANDARDS
Jeanie Arnoco
 

More from Jeanie Arnoco (20)

The Database Environment Chapter 15
The Database Environment Chapter 15The Database Environment Chapter 15
The Database Environment Chapter 15
 
The Database Environment Chapter 14
The Database Environment Chapter 14The Database Environment Chapter 14
The Database Environment Chapter 14
 
The Database Environment Chapter 13
The Database Environment Chapter 13The Database Environment Chapter 13
The Database Environment Chapter 13
 
The Database Environment Chapter 12
The Database Environment Chapter 12The Database Environment Chapter 12
The Database Environment Chapter 12
 
The Database Environment Chapter 11
The Database Environment Chapter 11The Database Environment Chapter 11
The Database Environment Chapter 11
 
The Database Environment Chapter 10
The Database Environment Chapter 10The Database Environment Chapter 10
The Database Environment Chapter 10
 
The Database Environment Chapter 9
The Database Environment Chapter 9The Database Environment Chapter 9
The Database Environment Chapter 9
 
The Database Environment Chapter 8
The Database Environment Chapter 8The Database Environment Chapter 8
The Database Environment Chapter 8
 
The Database Environment Chapter 7
The Database Environment Chapter 7The Database Environment Chapter 7
The Database Environment Chapter 7
 
The Database Environment Chapter 6
The Database Environment Chapter 6The Database Environment Chapter 6
The Database Environment Chapter 6
 
The Database Environment Chapter 5
The Database Environment Chapter 5The Database Environment Chapter 5
The Database Environment Chapter 5
 
The Database Environment Chapter 4
The Database Environment Chapter 4The Database Environment Chapter 4
The Database Environment Chapter 4
 
The Database Environment Chapter 3
The Database Environment Chapter 3The Database Environment Chapter 3
The Database Environment Chapter 3
 
The Database Environment Chapter 2
The Database Environment Chapter 2The Database Environment Chapter 2
The Database Environment Chapter 2
 
The Database Environment Chapter 1
The Database Environment Chapter 1The Database Environment Chapter 1
The Database Environment Chapter 1
 
Introduction to BOOTSTRAP
Introduction to BOOTSTRAPIntroduction to BOOTSTRAP
Introduction to BOOTSTRAP
 
Hacking and Online Security
Hacking and Online SecurityHacking and Online Security
Hacking and Online Security
 
(CAR)Cordillera Administrative Region
(CAR)Cordillera Administrative Region (CAR)Cordillera Administrative Region
(CAR)Cordillera Administrative Region
 
Quality Gurus Student
Quality Gurus StudentQuality Gurus Student
Quality Gurus Student
 
QUALITY STANDARDS
QUALITY STANDARDSQUALITY STANDARDS
QUALITY STANDARDS
 

Recently uploaded

CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 

Recently uploaded (20)

CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 

Quick sort-Data Structure

  • 2. This sorting algorithm uses the idea of divide and conquer. It finds the element called pivot which divides the array into two halves in such a way that elements in the left half are smaller than pivot and elements in the right half are greater than pivot. QUICK SORT
  • 3. Three steps Find pivot that divides the array into two halves. Quick sort the left half. Quick sort the right half. QUICK SORT
  • 4. Example Consider an array having 6 elements 5 2 6 1 3 4 Arrange the elements in ascending order using quick sort algorithm
  • 5. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array
  • 6. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array Left
  • 7. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array Left Initially pointing to the First element of the array
  • 8. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array Left Initially pointing to the First element of the array Right
  • 9. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array Left Initially pointing to the First element of the array Right Initially pointing to the Last element of the array
  • 10. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array Left Initially pointing to the First element of the array Right Initially pointing to the Last element of the array Pivot
  • 11. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array Left Initially pointing to the First element of the array Right Initially pointing to the Last element of the array Pivot Initially pointing to the First element
  • 12. 0 1 2 3 4 5 5 2 6 1 3 4 Array index Array element This is our unsorted array Left Initially pointing to the First element of the array Right Initially pointing to the Last element of the array Pivot Initially pointing to the First element We will quick sort this array
  • 13. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot
  • 14. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Remember this rule:
  • 15. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Remember this rule: All element to the RIGHT of pivot be GREATER than pivot.
  • 16. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Remember this rule: All element to the RIGHT of pivot be GREATER than pivot. All element to the LEFT of pivot be SMALLER than pivot.
  • 17. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot As the pivot is pointing at left
  • 18. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot As the pivot is pointing at left So we will start from right
  • 19. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot As the pivot is pointing at left So we will start from rightAnd move towards left
  • 20. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Pivot = 5 Right =4
  • 21. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Pivot = 5 Right =4 Is Pivot < Right ( 5 < 4)
  • 22. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Pivot = 5 Right =4 NO Is Pivot < Right ( 5 < 4)
  • 23. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Pivot = 5 Right =4 So we swap pivot and right NO Is Pivot < Right ( 5 < 4)
  • 24. 0 1 2 3 4 5 5 2 6 1 3 4 Left Right Pivot Pivot = 5 Right =4 So we swap pivot and right NO Is Pivot < Right ( 5 < 4)
  • 25. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Right =4 So we swap pivot and right NO Is Pivot < Right ( 5 < 4)
  • 26. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =4 Is Pivot < Left Now move pivot to right
  • 27. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =4 Is Pivot < Left NO So we swap pivot to the right
  • 28. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Now the pivot is pointing at right
  • 29. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Now the pivot is pointing at right So we will start from left
  • 30. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Now the pivot is pointing at right So we will start from left And move towards right
  • 31. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =4 Is Pivot > Left ( 5 > 4)
  • 32. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =4 Is Pivot > Left YES ( 5 > 4)
  • 33. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =4 Is Pivot > Left YES ( 5 > 4) So we move left one position towards right
  • 34. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =2 Is Pivot > Left ( 5 > 2)
  • 35. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =2 Is Pivot > Left ( 5 > 2) YES
  • 36. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =2 Is Pivot > Left ( 5 > 2) YES So we move left one position towards right
  • 37. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =6 Is Pivot > Left ( 5 > 6)
  • 38. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =6 Is Pivot > Left ( 5 > 6) NO
  • 39. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =6 Is Pivot > Left ( 5 > 6) NO So we swap pivot and left
  • 40. 0 1 2 3 4 5 4 2 6 1 3 5 Left Right Pivot Pivot = 5 Left =6 Is Pivot > Left ( 5 > 6) NO So we swap pivot and left
  • 41. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Left =6 Is Pivot > Left ( 5 > 6) NO So we swap pivot and left
  • 42. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Left =6 Is Pivot > Left ( 5 > 6) NO So we swap pivot and left And move the pivot to left
  • 43. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot
  • 44. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Now the pivot is pointing at left
  • 45. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Now the pivot is pointing at left So we will start from right
  • 46. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Now the pivot is pointing at left So we will start from right And move towards left
  • 47. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Right =6 Is Pivot < Right ( 5 < 6)
  • 48. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Right =6 Is Pivot < Right ( 5 < 6) YES
  • 49. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Right =6 Is Pivot < Right ( 5 < 6) YES So we move right one position towards left
  • 50. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Right =3 Is Pivot < Right ( 5 < 3)
  • 51. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Right =3 Is Pivot < Right ( 5 < 3) NO
  • 52. 0 1 2 3 4 5 4 2 5 1 3 6 Left Right Pivot Pivot = 5 Right =3 Is Pivot < Right ( 5 < 3) NO So we swap pivot and right
  • 53. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Pivot = 5 Right =3 Is Pivot < Right ( 5 < 3) NO So we swap pivot and right
  • 54. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Pivot = 5 Right =3 Is Pivot > Right ( 5 > 3) NO So we swap pivot and right And move the pivot to right
  • 55. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Pivot = 5 Left =3 Is Pivot > Left ( 5 > 3)
  • 56. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Pivot = 5 Left =3YES Is Pivot > Left ( 5 > 3)
  • 57. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Pivot = 5 Left =3 Is Pivot > Left ( 5 > 3) So we move left one position towards right YES
  • 58. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Pivot = 5 Left = 1 Is Pivot > Left ( 5 > 1)
  • 59. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot
  • 60. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Now both left and right are pointing at the same element of the array
  • 61. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Now both left and right are pointing at the same element of the array This time 5 is the pivot and it is at the sorted position 4 5
  • 62. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Now both left and right are pointing at the same element of the array This time 5 is the pivot and it is at the sorted position 4 5 Elements left of pivot are smaller
  • 63. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Now both left and right are pointing at the same element of the array This time 5 is the pivot and it is at the sorted position 4 5 Elements left of pivot are smaller Elements right of pivot are greater
  • 64. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Now both left and right are pointing at the same element of the array This time 5 is the pivot and it is at the sorted position 4 5 Elements left of pivot are smaller Elements right of pivot are greater So pivot has divided the array into two sub array
  • 65. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Now both left and right are pointing at the same element of the array This time 5 is the pivot and it is at the sorted position 4 5 Elements left of pivot are smaller Elements right of pivot are greater Left sub array Right sub array So pivot has divided the array into two sub array
  • 66. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Now both left and right are pointing at the same element of the array This time 5 is the pivot and it is at the sorted position 4 5 Elements left of pivot are smaller Elements right of pivot are greater Left sub array Right sub array So pivot has divided the array into two sub array We will now quick sort the left sub array
  • 67. 0 1 2 3 4 5 4 2 3 1 5 6 Left Right Pivot Pivot = 4 Left =1 Is Pivot < Left ( 4 < 1)
  • 68. 0 1 2 3 4 5 4 2 3 1 5 6 Pivot Pivot = 4 Left =1 Is Pivot < Left ( 4 < 1) NO Left Right
  • 69. 0 1 2 3 4 5 4 2 3 1 5 6 Pivot Pivot = 4 Left =1 Is Pivot < Left ( 4 < 1) NO So we swap pivot and right Left Right
  • 70. 0 1 2 3 4 5 1 2 3 4 5 6 Pivot Pivot = 4 Left =1 Is Pivot < Left ( 4 < 1) NO So we swap pivot and right Left Right
  • 71. 0 1 2 3 4 5 1 2 3 4 5 6 Left Right Pivot Pivot = 4 Left =1 Is Pivot < Left ( 4 < 1) NO So we swap pivot and right Now move the pivot to right
  • 72. 0 1 2 3 4 5 1 2 3 4 5 6 Pivot Pivot = 4 Left =1 Is Pivot < Left ( 4 < 1) NO So we swap pivot and right Left Right
  • 73. 0 1 2 3 4 5 1 2 3 4 5 6 The Array is Sorted