Class 3
Class 3
DESIGN
Lekha A
Computer Applications
ALGORITHMS – ANALYSIS AND
DESIGN
Introduction, Analysis Framework,
Brute Force Method
Efficiency of an algorithm
Lekha A
Computer Applications
ALGORITHMS – ANALYSIS AND DESIGN
Recap
• Analysis Framework
• Measuring an Input
• Orders of Growth
ALGORITHMS – ANALYSIS AND DESIGN
Efficiency
• Worst-case
• Best-case
• Average-case
ALGORITHMS – ANALYSIS AND DESIGN
Efficiency
• Example
• Sequential search
ALGORITHMS – ANALYSIS AND DESIGN
Algorithm – Sequential Search (A[0..n-1], k)
• i ←0
• i← i+1
• if i<n return i
• else return -1
ALGORITHMS – ANALYSIS AND DESIGN
Algorithm – Sequential Search (A[0..n-1], k)
the list.
ALGORITHMS – ANALYSIS AND DESIGN
Algorithm – Sequential Search (A[0..n-1], k)
• Cworst(n) = n
ALGORITHMS – ANALYSIS AND DESIGN
Algorithm – Sequential Search (A[0..n-1], k)
• It is the input of size n that make the algorithm run for the
an input (or inputs) of size n for which the algorithm runs the
accordingly,
• Cbest (n) = 1
ALGORITHMS – ANALYSIS AND DESIGN
Algorithm – Sequential Search (A[0..n-1], k)
• The best case doesn’t mean the small input; it means the
• Standard Assumptions
comparisons is
algorithm it is important.
ALGORITHMS – ANALYSIS AND DESIGN
Efficiencies - Amortized
structure.
• Efficiency
• Worst-case efficiency
• Best-case efficiency
• Average-case efficiency
• Example
Thank you
Lekha A
Computer Applications