Practice question · Put in order
Order the steps of modelling a problem before writing real code.
- Write those steps in plain pseudocode
- Identify the data: what quantities and entities, and what type is each
- State the assumptions and constraints the program must handle
- Define the algorithm as steps that transform input into output
Hints
- You must know what the data is before you can design steps that operate on it.
- Pseudocode records the algorithm; the constraints frame what it must cope with.
Show the answer
- Identify the data: what quantities and entities, and what type is each
- Define the algorithm as steps that transform input into output
- Write those steps in plain pseudocode
- State the assumptions and constraints the program must handle
Why
Name the data, design the algorithm, record it as pseudocode, and pin down the assumptions. Getting the logic right in pseudocode before real code lets you avoid fighting syntax while thinking, diving straight into code is the pitfall this lesson names.
Practise Simple Modelling with Code
The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Simple Modelling with Code
- Modelling a phone book as a dictionary rather than a list of pairs changes almost nothing about what the…
- Select every practice that the lesson recommends when modelling a problem.
- Choosing a fitting data representation is half the battle. Sort each quantity by the type that best models it.
- Storing money as a floating-point number is a well-known mistake. What actually goes wrong?