What's an algorithm?
- Computational procedure to solve a problem
- Mathematical abstraction of computer program
Model of computation specifies
- what operations an algorithm is allowed
- cost (time, space, . . .) of each operation
- cost of algorithm = sum of operation costs
Random Access Machine (RAM)
- Random Access Memory (RAM) modeled by a big array
- Θ(1) registers (each 1 word)
- In Θ(1) time, can: load word @ ri into register rj; compute (+, −, ∗, /, &, |, ˆ) on registers; store register rj into memory @ r;
Pointer Machine
- dynamically allocated objects
- object has O(1) fields
- field = word (e.g., int) or pointer to object/null (a.k.a. reference)
- weaker than RAM