Professional Documents
Culture Documents
Lec 1
Lec 1
• Analysis
• How does it work?
• Breaking a system down to known components
• How the components relate to each other
• Breaking a process down to known functions
• Synthesis
• Building tools and toys!
• What components are needed
• How the components should be put together
• Composing functions to form a process
Problem Solving Using Computers
• Problem:
• Strategy:
• Algorithm:
• Input:
• Output:
• Step:
• Analysis:
• Correctness:
• Time & Space:
• Optimality:
• Implementation:
• Verification:
Why need algorithm analysis ?
• Correctness
• Amount of work done, and space used
• Optimality, Simplicity
Correctness can be proved!
• Proving
• if the preconditions are satisfied,
• then the postconditions will be true,
• when the algorithm terminates.
Amount of work done
• Speed is fun!
Running Time
Worst-case: (usually)
• T(n) = maximum time of algorithm on any input of
size n.
Average-case: (sometimes)
• T(n) = expected time of algorithm over all inputs of
size n.
• Need assumption of statistical distribution of inputs.
Best-case:
• Cheat with a slow algorithm that works fast on some
input.
Machine-Independent time
Assumptions:
• Each simple operation such as +, -, if ...etc takes exactly
one time step.
• Loops and subroutines are not considered simple
operations.
• Each memory acces takes exactly one time step.
Machine-independent time
BIG IDEA:
• Ignore machine-dependent constants.
• Look at growth of T ( n) as n
“Asymptotic Analysis”
Asymptotic Analysis
Engineering:
•Example:
Asymptotic performance