Loose definition
Note
An algorithm…
- finishes in finite number of steps
- its answer is consistent
- it always gives the correct answer
Algorithm Design Principles
- Design
- What to compute
- How it computes what we want it to compute
- Correctness
- Why does it compute what we want it to compute
- Analysis & Efficiency
- How much resources does it use? (Complexity)
Most algorithms follow the following two standard models of computation
- Recursion
- Iteration
Verifying Correctness
Warning
There is no way to find out if an algorithm is correct.
- Mathematical Proof
- Direct Proof
- Mathematical Induction
- ⇒ Recursive algorithms looks similar to proof by induction
- Mathematical Induction
- Indirect Proof [=Proof by contradiction]
- Direct Proof
- Test experimentally