SlideShare a Scribd company logo
1 of 22
Mathematical
Analysis of
Algorithms
Mathematical Analysis of Non
recursive Algorithms
• Identify input size
• Identify Basic Operation
• Identify Case Complexity i.e. (Every Case,
Best Case, Worst Case, Average Case)
• Setup summation/recurrence relation
• solve summation/recurrence relation or
atleast order of growth of its relation
Finding largest element in array
Algorithm max_element(A,n)
maxval=A[0]
for i=1 to n-1
if A[i]>maxval
maxval=A[i]
Return maxval
• Input size : number of elements in array
• Basic operation : comparison
• Case complexity : Every Case
• Number of times basic operation executed
are
• T(n)=∑ 1=n-1є Ө (n)
i=1
n-1
Element uniqueness problem
Algorithm element_unique(A,n)
for i=0 to n-2
for j=i+1 to n-1
if A[i]==A[j]
return false
return true
• Input size : number of elements in array
• Basic operation : comparison of element of
Array
• Case complexity : Worst Case
• Number of times basic operation executed
are
T(n)=∑ ∑ 1 = ∑ [(n-1)-(i+1)+1]
=n(n-1)/2
i=0
n-2
j=i+1
n-1
i=0
n-2
Matrix Multiplication
Algorithm matrix_mul(A,B,C)
for i=1 to n
for j=1 to n
C[i,j]=0
for k=1 to n
C[i,j]=C[i,j]+A[i,k ]*B[k,j]
return C
• Input Size : order of matrix
• Basic operation:multiplication
• Case complexity: every case
• T(n)=∑ ∑ ∑ 1= ∑ ∑ n =∑
n2
= n3
n
i=1 j=1 k=1
n n
i=1 i=1
nn n
i=1
MATHEMATICAL ANALYSIS
OF RECURSIVE ALGORITHMS
Mathematical Analysis Of
Recursive Algorithms
• Identify input size
• Identify Basic Operation
• Identify Case Complexity i.e. (Every Case,
Best Case, Worst Case, Average Case)
• Setup recurrence relation
• solve recurrence relation or atleast order
of growth of its relation
Finding Factorial
Algorithm fact(n)
if n==0 return 1
else
return fact(n-1)*n
• Input size: 4 bytes
• Basic Operation: multiplication
• Case complexity: Every case
• Recurrence Relation: An equation or
inequality that describes function in terms
of its smaller inputs.
• to determine solution we need initial
condition that makes recursion stop.
• F(n)=F(n-1) *n for n>0 (Basic Operation)
M(n)=M(n-1) +1 (to multiply F(n-1) by n)
compute(F(n-1))
M(n-1)=(M(n-2)+1)
M(n-2)=(M(n-3)+1)
by substituting values backward
M(n-1)=M(n-3)+1+1
M(n)=M(n-3)+1+1+1
• M(n)=M(n-i)+i
we know the value of initial condition
M(0)=0
by taking i=n
M(n)=M(n-n)+n
=0+n=nєӨ(n)
Tower of hanoi
• Problem:
Algorithm hanoi(n,source,auxiliary,destination)
if n=1 move disk from source to destination
else
hanoi(n-1,source,destination,auxiliary)
move disk from source to destination
hanoi(n-1,auxiliary,source,destination)
• input size:number of diks, n
• Basic operation:move
• Case Complexity: Every case
so recurrence relation would be
• M(n)=M(n-1)+1+M(n-1)
=2M(n-1)+1
or M(n-1)=2M(n-2)+1
M(n-2)=2M(n-3)+1
Initial Condition: M(1)=1
by backward substituting values
M(n)=2M(n-1)+1
=2(2(M(n-2)+1)+1
=22
M(n-2)+2+1
=22
(2M(n-3)+1)+2+1
=23
M(n-3)+22
+2+1
By generalizing
=2i
M(n-i)+2i-1
+2i-2
+…+1
M(n)=2i
M(n-i)+2i-1
+2i-2
+…+1 geometric series
so
=2n-1
M(n-(n-1))+2n-1
-1
=2n-1
M(1)+2n-1
-1
=2n-1
+2n-1
-1
=2n
-1
• Recurrence Tree
Calculating number of bits to
store decimal number
Algorithm bincov(n)
if n=1 return 1
else
return bincov (floor(n/2))+1
• Input size: 4 bytes
• Basic operation: Summation
• complexity:every case
Recurrence Relation:
A(n)=A(floor(n/2))+1
initial condition:A(1)=0
• Smoothness rule: for solving problems of ceiling or
flooring assume that n= 2k
;
which claims under broad assumption order of growth
observed for n=2k
correct results for all values of n.
A(n)=A( n/2)+1
A(n/2)=A(n/4)+1
A(n/4)=A(n/8)+1
by backward substitution
A(n)=A(n/4)+2=A(n/8)+3=A(n/ 2k
)+k
by taking 2k
=n
A(n)=A(1)+k=k=lg(n)єӨ(lgn)

More Related Content

What's hot

Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithmRezwan Siam
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptracha49
 
Job sequencing with deadline
Job sequencing with deadlineJob sequencing with deadline
Job sequencing with deadlineArafat Hossan
 
Example of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional searchExample of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional searchAbhijeet Agarwal
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithmsDr Geetha Mohan
 
03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic AnalysisAndres Mendez-Vazquez
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solvingPrabhakaran V M
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of AlgorithmsBulbul Agrawal
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysissumitbardhan
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AIvikas dhakane
 
Lecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its PropertiesLecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its PropertiesRajesh K Shukla
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary searchZia Ush Shamszaman
 

What's hot (20)

5.1 greedy
5.1 greedy5.1 greedy
5.1 greedy
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Job sequencing with deadline
Job sequencing with deadlineJob sequencing with deadline
Job sequencing with deadline
 
Example of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional searchExample of iterative deepening search & bidirectional search
Example of iterative deepening search & bidirectional search
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Red black tree
Red black treeRed black tree
Red black tree
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
asymptotic notation
asymptotic notationasymptotic notation
asymptotic notation
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AII. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
 
Lecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its PropertiesLecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its Properties
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 

Viewers also liked

Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms IiSri Prasanna
 
02 order of growth
02 order of growth02 order of growth
02 order of growthHira Gul
 
Mathematical analysis of Graph and Huff amn coding
Mathematical analysis of Graph and Huff amn codingMathematical analysis of Graph and Huff amn coding
Mathematical analysis of Graph and Huff amn codingDr Anjan Krishnamurthy
 
Lec2 Algorth
Lec2 AlgorthLec2 Algorth
Lec2 Algorthhumanist3
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsSwapnil Agrawal
 

Viewers also liked (7)

SENZOS CV
SENZOS CVSENZOS CV
SENZOS CV
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
 
02 order of growth
02 order of growth02 order of growth
02 order of growth
 
Mathematical analysis of Graph and Huff amn coding
Mathematical analysis of Graph and Huff amn codingMathematical analysis of Graph and Huff amn coding
Mathematical analysis of Graph and Huff amn coding
 
Lec2 Algorth
Lec2 AlgorthLec2 Algorth
Lec2 Algorth
 
Mathematical analysis
Mathematical analysisMathematical analysis
Mathematical analysis
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 

Similar to 03 mathematical anaylsis

Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosluzenith_g
 
Number_Theory-1 number theory notes for engineering
Number_Theory-1 number theory notes for engineeringNumber_Theory-1 number theory notes for engineering
Number_Theory-1 number theory notes for engineeringrewiko3718
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................nourhandardeer3
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesjayavignesh86
 
Analysis and design of algorithms part2
Analysis and design of algorithms part2Analysis and design of algorithms part2
Analysis and design of algorithms part2Deepak John
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforcechidabdu
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
Perform brute force
Perform brute forcePerform brute force
Perform brute forceSHC
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0BG Java EE Course
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
lecture 10
lecture 10lecture 10
lecture 10sajinsc
 

Similar to 03 mathematical anaylsis (20)

Alg1
Alg1Alg1
Alg1
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmos
 
Number_Theory-1 number theory notes for engineering
Number_Theory-1 number theory notes for engineeringNumber_Theory-1 number theory notes for engineering
Number_Theory-1 number theory notes for engineering
 
algorithm Unit 2
algorithm Unit 2 algorithm Unit 2
algorithm Unit 2
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrences
 
Slide2
Slide2Slide2
Slide2
 
Analysis and design of algorithms part2
Analysis and design of algorithms part2Analysis and design of algorithms part2
Analysis and design of algorithms part2
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforce
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Perform brute force
Perform brute forcePerform brute force
Perform brute force
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
 
Merge sort
Merge sortMerge sort
Merge sort
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
lecture 10
lecture 10lecture 10
lecture 10
 
Ada notes
Ada notesAda notes
Ada notes
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 

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
 
08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15Hira Gul
 
04 brute force
04 brute force04 brute force
04 brute forceHira 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
 
08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15
 
07 dc3
07 dc307 dc3
07 dc3
 
06 dc2
06 dc206 dc2
06 dc2
 
05 dc1
05 dc105 dc1
05 dc1
 
04 brute force
04 brute force04 brute force
04 brute force
 
03 dc
03 dc03 dc
03 dc
 
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

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

03 mathematical anaylsis

  • 2. Mathematical Analysis of Non recursive Algorithms • Identify input size • Identify Basic Operation • Identify Case Complexity i.e. (Every Case, Best Case, Worst Case, Average Case) • Setup summation/recurrence relation • solve summation/recurrence relation or atleast order of growth of its relation
  • 3. Finding largest element in array Algorithm max_element(A,n) maxval=A[0] for i=1 to n-1 if A[i]>maxval maxval=A[i] Return maxval
  • 4. • Input size : number of elements in array • Basic operation : comparison • Case complexity : Every Case • Number of times basic operation executed are • T(n)=∑ 1=n-1є Ө (n) i=1 n-1
  • 5. Element uniqueness problem Algorithm element_unique(A,n) for i=0 to n-2 for j=i+1 to n-1 if A[i]==A[j] return false return true
  • 6. • Input size : number of elements in array • Basic operation : comparison of element of Array • Case complexity : Worst Case • Number of times basic operation executed are T(n)=∑ ∑ 1 = ∑ [(n-1)-(i+1)+1] =n(n-1)/2 i=0 n-2 j=i+1 n-1 i=0 n-2
  • 7. Matrix Multiplication Algorithm matrix_mul(A,B,C) for i=1 to n for j=1 to n C[i,j]=0 for k=1 to n C[i,j]=C[i,j]+A[i,k ]*B[k,j] return C
  • 8. • Input Size : order of matrix • Basic operation:multiplication • Case complexity: every case • T(n)=∑ ∑ ∑ 1= ∑ ∑ n =∑ n2 = n3 n i=1 j=1 k=1 n n i=1 i=1 nn n i=1
  • 10. Mathematical Analysis Of Recursive Algorithms • Identify input size • Identify Basic Operation • Identify Case Complexity i.e. (Every Case, Best Case, Worst Case, Average Case) • Setup recurrence relation • solve recurrence relation or atleast order of growth of its relation
  • 11. Finding Factorial Algorithm fact(n) if n==0 return 1 else return fact(n-1)*n
  • 12. • Input size: 4 bytes • Basic Operation: multiplication • Case complexity: Every case • Recurrence Relation: An equation or inequality that describes function in terms of its smaller inputs. • to determine solution we need initial condition that makes recursion stop.
  • 13. • F(n)=F(n-1) *n for n>0 (Basic Operation) M(n)=M(n-1) +1 (to multiply F(n-1) by n) compute(F(n-1)) M(n-1)=(M(n-2)+1) M(n-2)=(M(n-3)+1) by substituting values backward M(n-1)=M(n-3)+1+1 M(n)=M(n-3)+1+1+1
  • 14. • M(n)=M(n-i)+i we know the value of initial condition M(0)=0 by taking i=n M(n)=M(n-n)+n =0+n=nєӨ(n)
  • 15. Tower of hanoi • Problem:
  • 16. Algorithm hanoi(n,source,auxiliary,destination) if n=1 move disk from source to destination else hanoi(n-1,source,destination,auxiliary) move disk from source to destination hanoi(n-1,auxiliary,source,destination)
  • 17. • input size:number of diks, n • Basic operation:move • Case Complexity: Every case so recurrence relation would be • M(n)=M(n-1)+1+M(n-1) =2M(n-1)+1 or M(n-1)=2M(n-2)+1 M(n-2)=2M(n-3)+1
  • 18. Initial Condition: M(1)=1 by backward substituting values M(n)=2M(n-1)+1 =2(2(M(n-2)+1)+1 =22 M(n-2)+2+1 =22 (2M(n-3)+1)+2+1 =23 M(n-3)+22 +2+1 By generalizing =2i M(n-i)+2i-1 +2i-2 +…+1
  • 20. Calculating number of bits to store decimal number Algorithm bincov(n) if n=1 return 1 else return bincov (floor(n/2))+1
  • 21. • Input size: 4 bytes • Basic operation: Summation • complexity:every case Recurrence Relation: A(n)=A(floor(n/2))+1 initial condition:A(1)=0
  • 22. • Smoothness rule: for solving problems of ceiling or flooring assume that n= 2k ; which claims under broad assumption order of growth observed for n=2k correct results for all values of n. A(n)=A( n/2)+1 A(n/2)=A(n/4)+1 A(n/4)=A(n/8)+1 by backward substitution A(n)=A(n/4)+2=A(n/8)+3=A(n/ 2k )+k by taking 2k =n A(n)=A(1)+k=k=lg(n)єӨ(lgn)

Editor's Notes

  1. Summation(i=1 to n) 1 =1(n-1)+1 = summation number(upperlimeit-lower limit+1).
  2. Summation(k=1 to n)1=n;(1(n-1)+1)=n-1+1=n Sumation of (k=1 to n)n=n2 ;n(n-1)+n=n2-n+n=n2
  3. sumation i=1 to n x^i=(x^(n+1)-1)/(x-1)
  4. n=2^k lgn=klg(2) as lg(2)=1 so k= lgn