You are on page 1of 12

DESIGN AND ANALYSIS OF

ALGORITHMS
Lecture 2
Murtaza Mehdi
TOPICS
 Analysis of Algorithms
 Complexity Analysis
ALGORITHM ANALYSIS
 Analysis is the process of comparing two algorithms
with respect to time, space etc.

 Analysis is performed with respect to a computational


model.

 A process of determining the amount of ;me, resource,


etc. required when executing an algorithm.
TIME COMPLEXITY
 Is the algorithm “fast enough” for my needs

 How much longer will the algorithm take if I increase


the amount of data it must process

 Given a set of algorithms that accomplish the same


thing, which is the right one to choose
SPACE COMPLEXITY
 When memory was expensive we focused on making
programs as space efficient as possible.

 Space complexity is still important in the field of


embedded computing (hand held computer based
equipment like cell phones etc).
ALGORITHM ANALYSIS
 Empirical Approach

1. Time the implementation of algorithm


2. Real time results
3. Dependent on hardware
4. Development time, cost, verification.
ALGORITHM ANALYSIS
 Analytical/ Theoretical Approach

1. Inspect the pseudo code


2. Can analyze without implementation
3. No dependency on hardware
4. No dependency on software techniques
5. No dependency on programming languages
COMPLEXITY ANALYSIS
 Best Case Time
 Average Case Time

 Worst Case Time


BEST CASE TIME
 Best case runtime means that you are feeding the best
possible input into your algorithm

 For example,

1. An example of best-case is the outcome of an eye


surgery being perfect vision.
2. the best case for a sorting algorithm would be data
that's already sorted.
WORST CASE TIME
 Worst runtime means the longest running time
performed by an algorithm given any input of size n.

 For example,

1. An example of worst-case The worst-case scenario


is an aircraft will crash if a bird destroys an engine.
2. the worst case for a sorting algorithm might be data
that's sorted in reverse order.
MATRIX MULTIPLICATION
ANALYSIS OF ALGORITHM

You might also like