SlideShare a Scribd company logo
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 (20)

PPTX
State space search
chauhankapil
 
PPTX
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
PPTX
Lecture 17 Iterative Deepening a star algorithm
Hema Kashyap
 
PPTX
Greedy algorithms
sandeep54552
 
PPTX
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
PPTX
Travelling Salesman
Shuvojit Kar
 
PDF
Kmp
akruthi k
 
PPT
Recursion tree method
Rajendran
 
PPT
Memory allocation (4)
rockymani
 
PPT
UNIT-1-PPTS-DAA.ppt
racha49
 
PDF
State Space Search in ai
vikas dhakane
 
PPTX
NP completeness
Amrinder Arora
 
PPT
Asymptotic notations
Ehtisham Ali
 
PDF
Syntax Directed Definition and its applications
ShivanandManjaragi2
 
PPT
Thrashing allocation frames.43
myrajendra
 
PPTX
Performance analysis and randamized agoritham
lilyMalar1
 
PDF
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
PPTX
Asymptotic Notation
Protap Mondal
 
PPT
Greedy algorithms
Rajendran
 
PPTX
Knuth morris pratt string matching algo
sabiya sabiya
 
State space search
chauhankapil
 
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
Lecture 17 Iterative Deepening a star algorithm
Hema Kashyap
 
Greedy algorithms
sandeep54552
 
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
Travelling Salesman
Shuvojit Kar
 
Recursion tree method
Rajendran
 
Memory allocation (4)
rockymani
 
UNIT-1-PPTS-DAA.ppt
racha49
 
State Space Search in ai
vikas dhakane
 
NP completeness
Amrinder Arora
 
Asymptotic notations
Ehtisham Ali
 
Syntax Directed Definition and its applications
ShivanandManjaragi2
 
Thrashing allocation frames.43
myrajendra
 
Performance analysis and randamized agoritham
lilyMalar1
 
Binary Search - Design & Analysis of Algorithms
Drishti Bhalla
 
Asymptotic Notation
Protap Mondal
 
Greedy algorithms
Rajendran
 
Knuth morris pratt string matching algo
sabiya sabiya
 

Viewers also liked (7)

PDF
SENZOS CV
SENZOSENKOSI GUMEDE
 
PPT
Analysis Of Algorithms Ii
Sri Prasanna
 
PPT
02 order of growth
Hira Gul
 
PPT
Mathematical analysis of Graph and Huff amn coding
Dr Anjan Krishnamurthy
 
PDF
Lec2 Algorth
humanist3
 
PPTX
Mathematical analysis
Reymart Bargamento
 
PPT
Design and Analysis of Algorithms
Swapnil Agrawal
 
Analysis Of Algorithms Ii
Sri Prasanna
 
02 order of growth
Hira Gul
 
Mathematical analysis of Graph and Huff amn coding
Dr Anjan Krishnamurthy
 
Lec2 Algorth
humanist3
 
Mathematical analysis
Reymart Bargamento
 
Design and Analysis of Algorithms
Swapnil Agrawal
 
Ad

Similar to 03 mathematical anaylsis (20)

PDF
Analysis Framework for Analysis of Algorithms.pdf
Kiran K
 
PPT
Alg1
luzenith_g
 
PPT
Introducción al Análisis y diseño de algoritmos
luzenith_g
 
PPTX
Number_Theory-1 number theory notes for engineering
rewiko3718
 
DOC
algorithm Unit 2
Monika Choudhery
 
PPT
algo_vc_lecture8.ppt
Nehagupta259541
 
PPT
3. Recursion and Recurrences.ppt detail about recursive learning
KashifNadeem52
 
PDF
chapter1.pdf ......................................
nourhandardeer3
 
PDF
Lecture 5 6_7 - divide and conquer and method of solving recurrences
jayavignesh86
 
PPT
Slide2
Thiti Sununta
 
PPTX
designs and analysis of algorithmss.pptx
rachelevelynr9007sse
 
PPTX
Different Searching and Sorting Methods.pptx
Minakshee Patil
 
PDF
Analysis and design of algorithms part2
Deepak John
 
PDF
Sienna 3 bruteforce
chidabdu
 
PDF
Anlysis and design of algorithms part 1
Deepak John
 
PPT
Perform brute force
SHC
 
PPT
3-Chapter Three - Divide and Conquer.ppt
mershaabdisa
 
PPT
Algorithms with-java-advanced-1.0
BG Java EE Course
 
PDF
Daa chapter5
B.Kirron Reddi
 
PPTX
Brute force method
priyankabhansali217
 
Analysis Framework for Analysis of Algorithms.pdf
Kiran K
 
Introducción al Análisis y diseño de algoritmos
luzenith_g
 
Number_Theory-1 number theory notes for engineering
rewiko3718
 
algorithm Unit 2
Monika Choudhery
 
algo_vc_lecture8.ppt
Nehagupta259541
 
3. Recursion and Recurrences.ppt detail about recursive learning
KashifNadeem52
 
chapter1.pdf ......................................
nourhandardeer3
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
jayavignesh86
 
designs and analysis of algorithmss.pptx
rachelevelynr9007sse
 
Different Searching and Sorting Methods.pptx
Minakshee Patil
 
Analysis and design of algorithms part2
Deepak John
 
Sienna 3 bruteforce
chidabdu
 
Anlysis and design of algorithms part 1
Deepak John
 
Perform brute force
SHC
 
3-Chapter Three - Divide and Conquer.ppt
mershaabdisa
 
Algorithms with-java-advanced-1.0
BG Java EE Course
 
Daa chapter5
B.Kirron Reddi
 
Brute force method
priyankabhansali217
 
Ad

More from Hira Gul (11)

PPTX
Final iwvc
Hira Gul
 
PPTX
Oerating system project
Hira Gul
 
PPTX
project Judaism iwvc presentation
Hira Gul
 
PPT
09d transform & conquer spring2015
Hira Gul
 
PPTX
08 decrease and conquer spring 15
Hira Gul
 
PPT
07 dc3
Hira Gul
 
PPTX
06 dc2
Hira Gul
 
PPT
05 dc1
Hira Gul
 
PPT
04 brute force
Hira Gul
 
PPT
03 dc
Hira Gul
 
PPT
01 intro to algorithm--updated 2015
Hira Gul
 
Final iwvc
Hira Gul
 
Oerating system project
Hira Gul
 
project Judaism iwvc presentation
Hira Gul
 
09d transform & conquer spring2015
Hira Gul
 
08 decrease and conquer spring 15
Hira Gul
 
07 dc3
Hira Gul
 
06 dc2
Hira Gul
 
05 dc1
Hira Gul
 
04 brute force
Hira Gul
 
03 dc
Hira Gul
 
01 intro to algorithm--updated 2015
Hira Gul
 

Recently uploaded (20)

PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
Troubleshooting Virtual Threads in Java!
Tier1 app
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
What companies do with Pharo (ESUG 2025)
ESUG
 
PDF
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
PDF
Supabase Meetup: Build in a weekend, scale to millions
Carlo Gilmar Padilla Santana
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
PDF
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Troubleshooting Virtual Threads in Java!
Tier1 app
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
What companies do with Pharo (ESUG 2025)
ESUG
 
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
Supabase Meetup: Build in a weekend, scale to millions
Carlo Gilmar Padilla Santana
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
Presentation about variables and constant.pptx
kr2589474
 
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 

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

  • #5: Summation(i=1 to n) 1 =1(n-1)+1 = summation number(upperlimeit-lower limit+1).
  • #9: 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
  • #19: sumation i=1 to n x^i=(x^(n+1)-1)/(x-1)
  • #23: n=2^k lgn=klg(2) as lg(2)=1 so k= lgn