Data structures — Computing, 14–17 years
How a program arranges information so it can find, change and use it without getting lost.
Idea
A data structure is a chosen way to arrange information in a program. A list keeps items in an order, while a dictionary connects each key to a value, such as a student name to a mark. The choice affects how easily the program can find or change something.
Why it matters
A program soon has more information than a few separate variables can handle. Early programmers needed ways to store growing collections, search them and update them without writing every case by hand. Different structures solve different problems: order, quick lookup, or connections between items.
Worked example
Suppose a class has scores [8, 5, 9, 6]. To find whether 9 appears, a list can be checked from left to right: compare 8, then 5, then 9, and stop. If we also make a dictionary such as {"Ana":8, "Rui":9}, asking for Rui’s score goes straight to 9.
Common trap
A reasonable mistake is to choose the structure that looks most familiar, such as using a list for everything. It works in a tiny example, so the weakness stays hidden. With thousands of records, repeated searching may become slow, while a dictionary or another structure could make the same task much easier.
Where it appears
Music apps use lists for playlists, dictionaries for song details and graphs for links between artists or listeners. Maps also store places and roads as connected data. These choices are not decoration: they help an app answer questions such as “What comes next?” or “Which route connects these two places?”
Keep exploring
Other languages
Loading MyLeoNes™…