
Let’s think it through · Start with a story
The girl needs to find the tallest student in her class. The robot does not need to store shoe color, but it does need to store height and, when necessary, the student’s name.
Break down the process
- Real-world objectsStudents
- Relevant dataHeight and identity
- Computational goalMaximum height
- Return to realityThe student who has that height
Modeling turns a real-world task into data and relationships that can be computed.
Keep the information that affects the answer, but do not lose relationships the problem needs. If you must answer “Who is tallest?”, a list of heights alone is not enough.
01What does “modeling” mean?
Here, modeling does not mean creating a 3D model. It means:
02Which story details can be ignored?
Suppose a problem says, “Xiaoming takes a bus through several stops, and the number of passengers changes at each stop.”
If the only question is “What is the maximum number of passengers on the bus?”, its color, the weather, and the stop names may not matter.
03How do you find the data you really need?
Objects
What things appear in the problem?
Attributes
What useful data does each object have?
Relationships
How are the objects connected or affecting one another?
04When should you use an array?
If the objects form an ordered sequence of data—such as daily temperatures, student scores, or passenger counts at each stop on a route—an array is often a natural fit.
05When should you think of a graph?
If a problem describes general connections, such as cities and roads, friendships, or links between web pages, you can treat the objects as vertices and the connections as edges.
06What is a state?
A state is the minimum information needed to describe the “current situation” while solving a problem.
For a maze search, a basic state could be:
(row, col)
If the maze also has a key, the state may need to include:
(row, col, hasKey)
07Is a more detailed model always better?
No.
What you have learned
- Modeling turns a story into data and relationships.
- Remove background details that do not affect the answer.
- Arrays, trees, graphs, and states are common ways to represent information.
- A state should contain enough information, but should not grow for no reason.
- Good modeling often determines whether the next algorithm feels natural.
Next: How Do We Break a Big Problem into Smaller Problems?
Your turn
If you discard the students’ names and keep only their heights to sort them, can you still say directly who is tallest?
Have an answer? Click to see the explanation
Not reliably. Keep the identity along with the height, for example with a name, ID, or original position.