Problem Solving and Design
Algorithm Design and Problem Solving
Abstraction is the process of removing unnecessary detail from a problem so you can focus on the parts that matter.
A good model of a problem captures the essentials and leaves out the rest. The classic textbook example is the London Underground map: it hides the real geography of London (distances, road layouts, where the river runs) and shows only which stations connect to which lines, because that is the only information a traveller needs.

What to keep, what to throw away
When building a solution, you keep only the data and behaviour the program actually needs:
| For a school attendance system, KEEP... | THROW AWAY... |
|---|---|
| Student name and ID | Hair colour, favourite food, height |
| Attendance status (present/absent) per day | Mood, weather, lunch choice |
| Class group | Phone wallpaper |
A program that tracks every irrelevant fact would be slower, harder to write and harder to maintain.
Two kinds of abstraction
- Data abstraction: choosing which information about a real-world thing to store in the program (e.g. a student record stores name and attendance, not all biological data).
- Process abstraction: choosing what a piece of code does without worrying about how it does it (e.g.
calculate_percentage(presents, total)hides the multiplication and division behind a clean name).
Quick check
4 short questions on this note. See what has stuck, and where to look if something hasn't.