SlideShare a Scribd company logo
 Division of arrays in such a way that
 The sorted sub arrays do not need to be later
merged.
 This can be done by rearranging the elements in
A(1:n) such that
 A(i) <= A(j) for all i between 1 and m and all j
between m+1 and n.
 Thus the elements in A(1:m) and A(m+1: n) may
be independently sorted. No merge is needed
Instructor: Sadia Arshid
 To sort an array S
 If the number of elements in S is 0 or 1, then
return.
 Pick any element V in S. This is called pivot.
 Partition S-{V} (the remaining elements in S)
into two disjoint groups:
 S1= {x  S – {V} | x <= V},
 S2 = {x  S – {V} | x >= V}
 Return {quickSort(S1) followed by v followed
by quickSort(S2) }
Instructor: Sadia Arshid
Rearrange the array such that
 Element (pivot) is in its final position
 None of elements in A[1] .. A[m] is > pivot
 None of elements in A[m+1] .. A[n] is < pivot
pivot
elements lower
than pivot
elements higher
than pivot
 unsorted   unsorted 
Instructor: Sadia Arshid
Procedure quicksort(low,high)
If high>low
partition(low,high,Pivotpoint)
quicksort(low,pivotpint-1)
quicksort(pivotpoint+1,high)
Instructor: Sadia Arshid
procedure partition(low,high,pivotpoint)
pivotitem=s[low], j=low
for i=low+1 to high
if s[i]<pivotitm
j=j+1
exchange s[i] & s[j]
pivotpoint=j
exchange s[low] & s[pivotpoint]
Instructor: Sadia Arshid
The pivot is the smallest element all the time. Then
i = 0 and if we ignore T(0) = 0, which is insignificant,
the recurrence is
w(n)=case complexity of left side array + case
complexity of right side of array + complexity of
partition
in worst case left array would always b zero so right
array is of size n-1, n recursive call would be for n-1
elements
complexity of partition: n-1
Instructor: Sadia Arshid
w(n)=w(left subarray)+w(right subarray)+n-1
w(n)=w(0)+w(n-1)+n-1
=w(n-1)+n-1
w(n-1)=w(n-2)+n-2
w(n-2)=w(n-3)+n-3
by backward subsituation
w(n)=w(n-2)+n-2+n-1
=w(n-3)+n-3+n-2+n-1
……..
=w(1)+1+2+……..n-1
Instructor: Sadia Arshid
summation series of finite numbers
=n(n-1)/2 є O (n2 )
Instructor: Sadia Arshid
The pivot is the mid element all the time. Then
It equally divides array in two halves, the
recurrence is
T(n)=T(n/2)+T(n/2)+n-1
=2T(n/2)+n-1
………….
=nlgn-(n-1)єO(nlgn)
Instructor: Sadia Arshid
A(n)= 1/n∑ (A(p-1)+A(n-p))+n-1
1/n= probability each element to be pivot
item
A(p-1)+A(n-p)= average time to sort both left and
right sub array if p is pivot point
n-1=time to partition array
p=1
n
Instructor: Sadia Arshid
If pivot point p =1
Resultant sub arrays would be
A(0), A(n-1)
If p=2, A(1), A(n-2)
If p=3,A(2), A(n-3)
.
.
.
p=(n-2), A(n-3), A(2)
p=(n-1), A(n-2),A(1)
P=n,A(n-1),A(0)
Instructor: Sadia Arshid
As there is symmetry, and size of subarray is same for
p=1 & p=n-1, p=2 & p=n-2 …..
So to simplify equation we can say
2∑ A(p-1)=∑ A(p-1)+A(n-p)
Thus our equation would be
A(n)=2/n∑ A(p-1)+ n-1
nA(n)=2∑ A(p-1)+n(n-1)………..(1)
Similarly
(n-1)A(n-1)= 2∑ A(p-1) +(n-1)(n-2)………….(2)
p=1
n
p=
1
n
p=
1
n
p=
1
n
p=
1
n-1
Instructor: Sadia Arshid
by subtracting eq(2) from eq(1)
n A(n)-(n-1)A(n-1)=2A(n-1)+2(n-1)
nA(n)=(n+1)A(n-1)+2(n-1)
dividing whole eq with n(n+1)
A(n)/(n+1)=A(n-1)/n +2(n-1)/n(n+1)
to simplify equation assume
a(n)=A(n)/(n+1)
so
a(n)=a(n-1)+2(n-1)/n(n+1)
for larger value of n, (n-1)/(n+1)≈1
a(n)=a(n-1)+2/n for n>0, a(0)=0
a(n-1)=a(n-2)+2/n-1
a(n-2)=a(n-3)+2/n-2
by backward substitution
a(n-1)=a(n-3)+2/n-2+2/n-1
a(n)=a(n-1)+2/n-2+2/n-1+2/n
Instructor: Sadia Arshid
by generalizing equation
a(n)=a(n-i)+2∑1/k
terminating condition a(0)=0
by taking i=n
a(n)=a(0)+2∑ 1/k
=0+2ln(n), ln(n)=0.69 lg(n)
=1.38 lgn
as a(n)=A(n)/n+1
A(n)=1.38(n+1)lgnє O(nlgn)
k=0
i
K=1
n
Instructor: Sadia Arshid
Instructor: Sadia Arshid
procedure maxmin(i,j,fmax,fmin)
case:
i=j=fmax=fmin=S[i]
case:
i=j-1;if S[i]<S[j]; fmax=S[j], fmin=S[i]
else fmax=S[i],fmin=S[j]
else
mid=floor((i+j)/2)
maxmin(i,mid,gmax,gmin)
maxmin(mid+1,j,hmax,hmin)
fmax=max(gmax,hmax)
fmin=min(gmin,hmin)
Instructor: Sadia Arshid
 Input size=number of elements in array
 Basic operation: comparison, function call
 case complexity: every case
 recurrence relation:
 T(n)=T(floor(n/2))+T(ceil(n/2))+2
 base case: T(2)=1
by applying smoothness rule
 T(n)=2T(n/2)+2
Instructor: Sadia Arshid
T(n/2)=2T(n/4)+2
T(n/4)=2T(n/8)+2
by backward substitution
T(n)=2(2T(n/4)+2)+2
T(n)=22T(n/4)+22+2
=22(2T(n/8)+2)+22+2
=23T(n/8)+23+22+2
By generalizing
=2iT(n/2i)+2i+2i-1+…+2
=2iT(n/2i)+2(2i-1+2i-2+…….+1)
By applying geometric summation
=2iT(n/2i)+2(2i-1)
By taking 2i=n/2
=n/2T(2)+2(n/2-1)
=n/2+2n-2
=3n/2-2єӨ(n)
Instructor: Sadia Arshid

More Related Content

What's hot

Eigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to DiagonalisationEigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to DiagonalisationChristopher Gratton
 
Eigen values and eigen vectors
Eigen values and eigen vectorsEigen values and eigen vectors
Eigen values and eigen vectorsRiddhi Patel
 
3º mat pc_e_03_septiembre-alumno
3º mat pc_e_03_septiembre-alumno3º mat pc_e_03_septiembre-alumno
3º mat pc_e_03_septiembre-alumnovaradir1983
 
Design & Analysis of Algorithms Techniques
Design & Analysis of Algorithms TechniquesDesign & Analysis of Algorithms Techniques
Design & Analysis of Algorithms TechniquesM Jawad Bashir
 
Review of linear algebra
Review of linear algebraReview of linear algebra
Review of linear algebraHiroki Sayama
 
Machine Learning - Regression model
Machine Learning - Regression modelMachine Learning - Regression model
Machine Learning - Regression modelRADO7900
 
Maths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectorsMaths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectorsJaydev Kishnani
 
Addition of Vectors | By Head to Tail Rule
Addition of Vectors | By Head to Tail RuleAddition of Vectors | By Head to Tail Rule
Addition of Vectors | By Head to Tail RuleAdeel Rasheed
 
Eigenvalues and eigenvectors
Eigenvalues and eigenvectorsEigenvalues and eigenvectors
Eigenvalues and eigenvectorsiraq
 
Numerical Methods - Power Method for Eigen values
Numerical Methods - Power Method for Eigen valuesNumerical Methods - Power Method for Eigen values
Numerical Methods - Power Method for Eigen valuesDr. Nirav Vyas
 
Vectors
VectorsVectors
Vectorskleybf
 
Positive matrix by sarmad baloch
Positive matrix by sarmad balochPositive matrix by sarmad baloch
Positive matrix by sarmad balochSarmad Baloch
 
Seismic data processing (mathematical foundations)
Seismic data processing (mathematical foundations)Seismic data processing (mathematical foundations)
Seismic data processing (mathematical foundations)Amin khalil
 
Vectors space definition with axiom classification
Vectors space definition with axiom classificationVectors space definition with axiom classification
Vectors space definition with axiom classificationkishor pokar
 
Eigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theoremEigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theoremgidc engineering college
 

What's hot (20)

Eigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to DiagonalisationEigenvectors & Eigenvalues: The Road to Diagonalisation
Eigenvectors & Eigenvalues: The Road to Diagonalisation
 
Eigen values and eigen vectors
Eigen values and eigen vectorsEigen values and eigen vectors
Eigen values and eigen vectors
 
3º mat pc_e_03_septiembre-alumno
3º mat pc_e_03_septiembre-alumno3º mat pc_e_03_septiembre-alumno
3º mat pc_e_03_septiembre-alumno
 
Design & Analysis of Algorithms Techniques
Design & Analysis of Algorithms TechniquesDesign & Analysis of Algorithms Techniques
Design & Analysis of Algorithms Techniques
 
Review of linear algebra
Review of linear algebraReview of linear algebra
Review of linear algebra
 
Machine Learning - Regression model
Machine Learning - Regression modelMachine Learning - Regression model
Machine Learning - Regression model
 
Maths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectorsMaths-->>Eigenvalues and eigenvectors
Maths-->>Eigenvalues and eigenvectors
 
Addition of Vectors | By Head to Tail Rule
Addition of Vectors | By Head to Tail RuleAddition of Vectors | By Head to Tail Rule
Addition of Vectors | By Head to Tail Rule
 
Eigenvalues and eigenvectors
Eigenvalues and eigenvectorsEigenvalues and eigenvectors
Eigenvalues and eigenvectors
 
Numerical Methods - Power Method for Eigen values
Numerical Methods - Power Method for Eigen valuesNumerical Methods - Power Method for Eigen values
Numerical Methods - Power Method for Eigen values
 
Vectors
VectorsVectors
Vectors
 
Lecture 05
Lecture 05Lecture 05
Lecture 05
 
Positive matrix by sarmad baloch
Positive matrix by sarmad balochPositive matrix by sarmad baloch
Positive matrix by sarmad baloch
 
Seismic data processing (mathematical foundations)
Seismic data processing (mathematical foundations)Seismic data processing (mathematical foundations)
Seismic data processing (mathematical foundations)
 
1640 vector-maths
1640 vector-maths1640 vector-maths
1640 vector-maths
 
Maths
MathsMaths
Maths
 
Vectors space definition with axiom classification
Vectors space definition with axiom classificationVectors space definition with axiom classification
Vectors space definition with axiom classification
 
Interpreting Free Body Diagrams
Interpreting Free Body DiagramsInterpreting Free Body Diagrams
Interpreting Free Body Diagrams
 
Interpreting Free Body Diagrams
Interpreting Free Body DiagramsInterpreting Free Body Diagrams
Interpreting Free Body Diagrams
 
Eigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theoremEigen value , eigen vectors, caley hamilton theorem
Eigen value , eigen vectors, caley hamilton theorem
 

Similar to 06 dc2

08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15Hira Gul
 
SVD review
SVD reviewSVD review
SVD reviewnextlib
 
Let Universe has size n.Then set of disjoint sets will be {) and U.pdf
Let Universe has size n.Then set of disjoint sets will be {) and U.pdfLet Universe has size n.Then set of disjoint sets will be {) and U.pdf
Let Universe has size n.Then set of disjoint sets will be {) and U.pdfkareemangels
 
Algebraic techniques in combinatorics
Algebraic techniques in combinatoricsAlgebraic techniques in combinatorics
Algebraic techniques in combinatoricsVui Lên Bạn Nhé
 
Complex Numbers and Functions. Complex Differentiation
Complex Numbers and Functions. Complex DifferentiationComplex Numbers and Functions. Complex Differentiation
Complex Numbers and Functions. Complex DifferentiationHesham Ali
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxVishalDeshpande27
 
Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)shamimakamili
 

Similar to 06 dc2 (20)

08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15
 
Power series
Power seriesPower series
Power series
 
SVD review
SVD reviewSVD review
SVD review
 
Brute force
Brute forceBrute force
Brute force
 
Let Universe has size n.Then set of disjoint sets will be {) and U.pdf
Let Universe has size n.Then set of disjoint sets will be {) and U.pdfLet Universe has size n.Then set of disjoint sets will be {) and U.pdf
Let Universe has size n.Then set of disjoint sets will be {) and U.pdf
 
Algebraic techniques in combinatorics
Algebraic techniques in combinatoricsAlgebraic techniques in combinatorics
Algebraic techniques in combinatorics
 
Range-NUllity-and-Rank.pptx
Range-NUllity-and-Rank.pptxRange-NUllity-and-Rank.pptx
Range-NUllity-and-Rank.pptx
 
Thara
TharaThara
Thara
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
Complex Numbers and Functions. Complex Differentiation
Complex Numbers and Functions. Complex DifferentiationComplex Numbers and Functions. Complex Differentiation
Complex Numbers and Functions. Complex Differentiation
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
 
Fourier series 3
Fourier series 3Fourier series 3
Fourier series 3
 
April_09.ppt
April_09.pptApril_09.ppt
April_09.ppt
 
Determinants
DeterminantsDeterminants
Determinants
 
Ch3_Z-transform.pdf
Ch3_Z-transform.pdfCh3_Z-transform.pdf
Ch3_Z-transform.pdf
 
ch16.pptx
ch16.pptxch16.pptx
ch16.pptx
 
ch16 (1).pptx
ch16 (1).pptxch16 (1).pptx
ch16 (1).pptx
 
Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)
 
Symmetrics groups
Symmetrics groupsSymmetrics groups
Symmetrics groups
 
Number theory lecture (part 1)
Number theory lecture (part 1)Number theory lecture (part 1)
Number theory lecture (part 1)
 

More from Hira Gul

Final iwvc
Final iwvcFinal iwvc
Final iwvcHira Gul
 
Oerating system project
Oerating system projectOerating system project
Oerating system projectHira Gul
 
project Judaism iwvc presentation
project Judaism iwvc presentation project Judaism iwvc presentation
project Judaism iwvc presentation Hira Gul
 
09d transform & conquer spring2015
09d transform & conquer spring201509d transform & conquer spring2015
09d transform & conquer spring2015Hira Gul
 
04 brute force
04 brute force04 brute force
04 brute forceHira Gul
 
03 mathematical anaylsis
03 mathematical anaylsis03 mathematical anaylsis
03 mathematical anaylsisHira Gul
 
02 order of growth
02 order of growth02 order of growth
02 order of growthHira Gul
 
01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015Hira Gul
 

More from Hira Gul (11)

Final iwvc
Final iwvcFinal iwvc
Final iwvc
 
Oerating system project
Oerating system projectOerating system project
Oerating system project
 
project Judaism iwvc presentation
project Judaism iwvc presentation project Judaism iwvc presentation
project Judaism iwvc presentation
 
09d transform & conquer spring2015
09d transform & conquer spring201509d transform & conquer spring2015
09d transform & conquer spring2015
 
07 dc3
07 dc307 dc3
07 dc3
 
05 dc1
05 dc105 dc1
05 dc1
 
04 brute force
04 brute force04 brute force
04 brute force
 
03 mathematical anaylsis
03 mathematical anaylsis03 mathematical anaylsis
03 mathematical anaylsis
 
03 dc
03 dc03 dc
03 dc
 
02 order of growth
02 order of growth02 order of growth
02 order of growth
 
01 intro to algorithm--updated 2015
01 intro to algorithm--updated 201501 intro to algorithm--updated 2015
01 intro to algorithm--updated 2015
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 

06 dc2

  • 1.  Division of arrays in such a way that  The sorted sub arrays do not need to be later merged.  This can be done by rearranging the elements in A(1:n) such that  A(i) <= A(j) for all i between 1 and m and all j between m+1 and n.  Thus the elements in A(1:m) and A(m+1: n) may be independently sorted. No merge is needed Instructor: Sadia Arshid
  • 2.  To sort an array S  If the number of elements in S is 0 or 1, then return.  Pick any element V in S. This is called pivot.  Partition S-{V} (the remaining elements in S) into two disjoint groups:  S1= {x  S – {V} | x <= V},  S2 = {x  S – {V} | x >= V}  Return {quickSort(S1) followed by v followed by quickSort(S2) } Instructor: Sadia Arshid
  • 3. Rearrange the array such that  Element (pivot) is in its final position  None of elements in A[1] .. A[m] is > pivot  None of elements in A[m+1] .. A[n] is < pivot pivot elements lower than pivot elements higher than pivot  unsorted   unsorted  Instructor: Sadia Arshid
  • 5. procedure partition(low,high,pivotpoint) pivotitem=s[low], j=low for i=low+1 to high if s[i]<pivotitm j=j+1 exchange s[i] & s[j] pivotpoint=j exchange s[low] & s[pivotpoint] Instructor: Sadia Arshid
  • 6. The pivot is the smallest element all the time. Then i = 0 and if we ignore T(0) = 0, which is insignificant, the recurrence is w(n)=case complexity of left side array + case complexity of right side of array + complexity of partition in worst case left array would always b zero so right array is of size n-1, n recursive call would be for n-1 elements complexity of partition: n-1 Instructor: Sadia Arshid
  • 7. w(n)=w(left subarray)+w(right subarray)+n-1 w(n)=w(0)+w(n-1)+n-1 =w(n-1)+n-1 w(n-1)=w(n-2)+n-2 w(n-2)=w(n-3)+n-3 by backward subsituation w(n)=w(n-2)+n-2+n-1 =w(n-3)+n-3+n-2+n-1 …….. =w(1)+1+2+……..n-1 Instructor: Sadia Arshid
  • 8. summation series of finite numbers =n(n-1)/2 є O (n2 ) Instructor: Sadia Arshid
  • 9. The pivot is the mid element all the time. Then It equally divides array in two halves, the recurrence is T(n)=T(n/2)+T(n/2)+n-1 =2T(n/2)+n-1 …………. =nlgn-(n-1)єO(nlgn) Instructor: Sadia Arshid
  • 10. A(n)= 1/n∑ (A(p-1)+A(n-p))+n-1 1/n= probability each element to be pivot item A(p-1)+A(n-p)= average time to sort both left and right sub array if p is pivot point n-1=time to partition array p=1 n Instructor: Sadia Arshid
  • 11. If pivot point p =1 Resultant sub arrays would be A(0), A(n-1) If p=2, A(1), A(n-2) If p=3,A(2), A(n-3) . . . p=(n-2), A(n-3), A(2) p=(n-1), A(n-2),A(1) P=n,A(n-1),A(0) Instructor: Sadia Arshid
  • 12. As there is symmetry, and size of subarray is same for p=1 & p=n-1, p=2 & p=n-2 ….. So to simplify equation we can say 2∑ A(p-1)=∑ A(p-1)+A(n-p) Thus our equation would be A(n)=2/n∑ A(p-1)+ n-1 nA(n)=2∑ A(p-1)+n(n-1)………..(1) Similarly (n-1)A(n-1)= 2∑ A(p-1) +(n-1)(n-2)………….(2) p=1 n p= 1 n p= 1 n p= 1 n p= 1 n-1 Instructor: Sadia Arshid
  • 13. by subtracting eq(2) from eq(1) n A(n)-(n-1)A(n-1)=2A(n-1)+2(n-1) nA(n)=(n+1)A(n-1)+2(n-1) dividing whole eq with n(n+1) A(n)/(n+1)=A(n-1)/n +2(n-1)/n(n+1) to simplify equation assume a(n)=A(n)/(n+1) so a(n)=a(n-1)+2(n-1)/n(n+1) for larger value of n, (n-1)/(n+1)≈1 a(n)=a(n-1)+2/n for n>0, a(0)=0 a(n-1)=a(n-2)+2/n-1 a(n-2)=a(n-3)+2/n-2 by backward substitution a(n-1)=a(n-3)+2/n-2+2/n-1 a(n)=a(n-1)+2/n-2+2/n-1+2/n Instructor: Sadia Arshid
  • 14. by generalizing equation a(n)=a(n-i)+2∑1/k terminating condition a(0)=0 by taking i=n a(n)=a(0)+2∑ 1/k =0+2ln(n), ln(n)=0.69 lg(n) =1.38 lgn as a(n)=A(n)/n+1 A(n)=1.38(n+1)lgnє O(nlgn) k=0 i K=1 n Instructor: Sadia Arshid
  • 16. procedure maxmin(i,j,fmax,fmin) case: i=j=fmax=fmin=S[i] case: i=j-1;if S[i]<S[j]; fmax=S[j], fmin=S[i] else fmax=S[i],fmin=S[j] else mid=floor((i+j)/2) maxmin(i,mid,gmax,gmin) maxmin(mid+1,j,hmax,hmin) fmax=max(gmax,hmax) fmin=min(gmin,hmin) Instructor: Sadia Arshid
  • 17.  Input size=number of elements in array  Basic operation: comparison, function call  case complexity: every case  recurrence relation:  T(n)=T(floor(n/2))+T(ceil(n/2))+2  base case: T(2)=1 by applying smoothness rule  T(n)=2T(n/2)+2 Instructor: Sadia Arshid
  • 18. T(n/2)=2T(n/4)+2 T(n/4)=2T(n/8)+2 by backward substitution T(n)=2(2T(n/4)+2)+2 T(n)=22T(n/4)+22+2 =22(2T(n/8)+2)+22+2 =23T(n/8)+23+22+2 By generalizing =2iT(n/2i)+2i+2i-1+…+2 =2iT(n/2i)+2(2i-1+2i-2+…….+1) By applying geometric summation =2iT(n/2i)+2(2i-1) By taking 2i=n/2 =n/2T(2)+2(n/2-1) =n/2+2n-2 =3n/2-2єӨ(n) Instructor: Sadia Arshid