AP uses its own pseudocode on the exam. Key differences from most languages:
- Lists start at index 1, not 0.
- Assignment uses an arrow:
x ← 5. REPEAT n TIMES,REPEAT UNTIL (condition), andFOR EACH item IN list.- List procedures:
APPEND,INSERT,REMOVE,LENGTH.
Key ideas
- Algorithms combine sequencing, selection, and iteration.
- Linear search works on any list; binary search is much faster but requires sorted data.
- Efficiency: polynomial-time algorithms are "reasonable"; exponential-time ones are "unreasonable" for large inputs. Heuristics give good-enough answers when exact solutions take too long.
- Some problems are undecidable: no algorithm can solve every case (the halting problem).
- Procedural abstraction hides details behind a named procedure, making programs easier to read and reuse.