6.1210 Introduction to Algorithms
Definition of an algorithm
An algorithm is a procedure for solving a computational problem.
- In this class, we want algorithms that are correct and efficient.
An algorithm is correct when it gives a correct answer for every possible input. An algorithm is efficient if it uses few resources (number of operations, memory, etc.).
Efficiency
- π We measure resource usage asymptotically as a function of the input size.
- π We start with worst-case analysis: for all input of the same size , we measure the resources used on the worst possible input.
- Later in the course, we discuss average-case analysis.
- For an algorithm , we denote the runtime of on the worst input of size as
Asymptotic notation
- Upper bounds: has worst-case runtime iff there exists a constant and such that, for all , and for every input of length , algorithm uses no more than operations on input . [similar structure to the definition of convergence in real analysis?]
- Lower bounds: has worst-case runtime iff there exists a constant and such that, for all , there exists an input of length , such that algorithm uses at least operations on input .