SlideShare una empresa de Scribd logo
1 de 5
Quick Sort Analysis
3 3 3 3 3
J,i Pivot i+1 x
Worst case
q = Partion(A,p,r) …….> cn
Quicksort(A,p,q-1)--
Quicksort(A, q+1,r) 1,2 3,4,5
1
4,3,2,5
4,3,2 5
3
2
4
3,4
cn
cn
cn
cn
n-1 + n-2 +n-3 +n-4……………1 = O(n^2)
Merge Sort
7 3 2 16 20 24 5 9
2 3 5 7 9 16 20 24
7 3 2 16
2 3 7 16
20 24 5 9
5 9 20 24
7 3
3 7
i
5 9
5 9
i j
20 24
20 24
i j
2 16
2 16
j
7 ∞
i
2
i
16
j
20
i
24
j
5
i
9
j
3 ∞
j
2 3 7 16
i
5 9 20 24
j
2 3 5 7 9 16 20 24
1 2 3 4 5 6 7 8
p q
=floor
(
p+r/2)
L R
A
Merge(A,p,q,r)
{
n1 = q-p+1
n2 = r-q
Let L[1…n1+1 ] and R [1
to n2 +1] be new arrays
for(i=1 to n1)
L[i] = A[p+i-1]
for (j=1 to n2)
R[j] =A[q+j]
L[n1+1] = ∞
R[n2+1]= ∞
i=1 ; j=1
for (k=p to r)
if(L[i]<= R[j]
A[k] =L[i]
i= i+1
else
A[k] =R[j]
j=j+1
}
2 3 7 16
i
5 9 20 24
j
2 3 5 7 9 16 20 24
1 2 3 4 5 6 7 8
p q
=floor
(
p+r/2)
L R
A
Mergesort (A,p,r)
{
If p<r
q = floor((p+r)/2)
mergesort(A,p,q)
mergesort(A,q+1,r)
merge(A,p,q,r)
}

Más contenido relacionado

Similar a Quick Sort Analysis.pptx

طراحی الگوریتم فصل 1
طراحی الگوریتم فصل 1طراحی الگوریتم فصل 1
طراحی الگوریتم فصل 1Saeed Sarshar
 
cps170_bayes_nets.ppt
cps170_bayes_nets.pptcps170_bayes_nets.ppt
cps170_bayes_nets.pptFaizAbaas
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisQuick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisSNJ Chaudhary
 
ロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズJunpei Tsuji
 
Control as Inference (強化学習とベイズ統計)
Control as Inference (強化学習とベイズ統計)Control as Inference (強化学習とベイズ統計)
Control as Inference (強化学習とベイズ統計)Shohei Taniguchi
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-SortTareq Hasan
 
ゲーム理論BASIC 演習52 -完全ベイジアン均衡-
ゲーム理論BASIC 演習52 -完全ベイジアン均衡-ゲーム理論BASIC 演習52 -完全ベイジアン均衡-
ゲーム理論BASIC 演習52 -完全ベイジアン均衡-ssusere0a682
 
ゲーム理論BASIC 演習51 -完全ベイジアン均衡-
ゲーム理論BASIC 演習51 -完全ベイジアン均衡-ゲーム理論BASIC 演習51 -完全ベイジアン均衡-
ゲーム理論BASIC 演習51 -完全ベイジアン均衡-ssusere0a682
 
Orthogonal basis and gram schmidth process
Orthogonal basis and gram schmidth processOrthogonal basis and gram schmidth process
Orthogonal basis and gram schmidth processgidc engineering college
 
11 x1 t11 05 tangents & normals i (2013)
11 x1 t11 05 tangents & normals i (2013)11 x1 t11 05 tangents & normals i (2013)
11 x1 t11 05 tangents & normals i (2013)Nigel Simmons
 
On Steiner Dominating Sets and Steiner Domination Polynomials of Paths
On Steiner Dominating Sets and Steiner Domination Polynomials of PathsOn Steiner Dominating Sets and Steiner Domination Polynomials of Paths
On Steiner Dominating Sets and Steiner Domination Polynomials of PathsIJERA Editor
 
Top school in noida
Top school in noidaTop school in noida
Top school in noidaEdhole.com
 
ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-
ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-
ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-ssusere0a682
 
Selection sort(sorting algorithm in data structure) and its time complexity
Selection sort(sorting algorithm in data structure) and its time complexitySelection sort(sorting algorithm in data structure) and its time complexity
Selection sort(sorting algorithm in data structure) and its time complexityComputer_ at_home
 

Similar a Quick Sort Analysis.pptx (20)

طراحی الگوریتم فصل 1
طراحی الگوریتم فصل 1طراحی الگوریتم فصل 1
طراحی الگوریتم فصل 1
 
cps170_bayes_nets.ppt
cps170_bayes_nets.pptcps170_bayes_nets.ppt
cps170_bayes_nets.ppt
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisQuick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And Analysis
 
ロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズ
 
Control as Inference (強化学習とベイズ統計)
Control as Inference (強化学習とベイズ統計)Control as Inference (強化学習とベイズ統計)
Control as Inference (強化学習とベイズ統計)
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 
Chapter 2 sequencess and series
Chapter 2 sequencess and seriesChapter 2 sequencess and series
Chapter 2 sequencess and series
 
ゲーム理論BASIC 演習52 -完全ベイジアン均衡-
ゲーム理論BASIC 演習52 -完全ベイジアン均衡-ゲーム理論BASIC 演習52 -完全ベイジアン均衡-
ゲーム理論BASIC 演習52 -完全ベイジアン均衡-
 
ゲーム理論BASIC 演習51 -完全ベイジアン均衡-
ゲーム理論BASIC 演習51 -完全ベイジアン均衡-ゲーム理論BASIC 演習51 -完全ベイジアン均衡-
ゲーム理論BASIC 演習51 -完全ベイジアン均衡-
 
Orthogonal basis and gram schmidth process
Orthogonal basis and gram schmidth processOrthogonal basis and gram schmidth process
Orthogonal basis and gram schmidth process
 
3.8 quicksort
3.8 quicksort3.8 quicksort
3.8 quicksort
 
11 x1 t11 05 tangents & normals i (2013)
11 x1 t11 05 tangents & normals i (2013)11 x1 t11 05 tangents & normals i (2013)
11 x1 t11 05 tangents & normals i (2013)
 
On Steiner Dominating Sets and Steiner Domination Polynomials of Paths
On Steiner Dominating Sets and Steiner Domination Polynomials of PathsOn Steiner Dominating Sets and Steiner Domination Polynomials of Paths
On Steiner Dominating Sets and Steiner Domination Polynomials of Paths
 
3D Geometry QA 9
3D Geometry QA 93D Geometry QA 9
3D Geometry QA 9
 
Top school in noida
Top school in noidaTop school in noida
Top school in noida
 
ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-
ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-
ゲーム理論BASIC 演習42 -2人ゼロ和ゲームにおけるマックスミニ値2-
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...
2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...
2018 MUMS Fall Course - Statistical and Mathematical Techniques for Sensitivi...
 
Differential equations
Differential equationsDifferential equations
Differential equations
 
Selection sort(sorting algorithm in data structure) and its time complexity
Selection sort(sorting algorithm in data structure) and its time complexitySelection sort(sorting algorithm in data structure) and its time complexity
Selection sort(sorting algorithm in data structure) and its time complexity
 

Último

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfrs7054576148
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 

Último (20)

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 

Quick Sort Analysis.pptx

  • 1. Quick Sort Analysis 3 3 3 3 3 J,i Pivot i+1 x Worst case q = Partion(A,p,r) …….> cn Quicksort(A,p,q-1)-- Quicksort(A, q+1,r) 1,2 3,4,5 1 4,3,2,5 4,3,2 5 3 2 4 3,4 cn cn cn cn n-1 + n-2 +n-3 +n-4……………1 = O(n^2)
  • 2. Merge Sort 7 3 2 16 20 24 5 9 2 3 5 7 9 16 20 24 7 3 2 16 2 3 7 16 20 24 5 9 5 9 20 24 7 3 3 7 i 5 9 5 9 i j 20 24 20 24 i j 2 16 2 16 j 7 ∞ i 2 i 16 j 20 i 24 j 5 i 9 j 3 ∞ j
  • 3. 2 3 7 16 i 5 9 20 24 j 2 3 5 7 9 16 20 24 1 2 3 4 5 6 7 8 p q =floor ( p+r/2) L R A
  • 4. Merge(A,p,q,r) { n1 = q-p+1 n2 = r-q Let L[1…n1+1 ] and R [1 to n2 +1] be new arrays for(i=1 to n1) L[i] = A[p+i-1] for (j=1 to n2) R[j] =A[q+j] L[n1+1] = ∞ R[n2+1]= ∞ i=1 ; j=1 for (k=p to r) if(L[i]<= R[j] A[k] =L[i] i= i+1 else A[k] =R[j] j=j+1 } 2 3 7 16 i 5 9 20 24 j 2 3 5 7 9 16 20 24 1 2 3 4 5 6 7 8 p q =floor ( p+r/2) L R A
  • 5. Mergesort (A,p,r) { If p<r q = floor((p+r)/2) mergesort(A,p,q) mergesort(A,q+1,r) merge(A,p,q,r) }