MyLeoNes™

Trees: nested relationships — Computing, 11–13

A tree organises information in levels, with one starting point and branches below it. It is useful when things belong inside other things, such as folders, family links, or choices in a game.

What a tree looks like

In computing, a tree is a set of connected items arranged from a root into branches. Each item can have children, but normally one item has only one parent; the root has none. A folder containing folders is a tree you can open with your eyes, even though the computer stores the links more abstractly.

Why use trees?

A flat collection becomes awkward when its items have layers or parents. A tree keeps those relationships visible, so a program can move from a folder to its contents or from a question to its next choices. The idea grew from the need to represent hierarchies, not from a wish to copy nature.

Reading a folder tree

Suppose School is the root. It contains Maths and Art. Maths contains Algebra and Geometry, while Art contains Drawing. To find Geometry, start at School, follow Maths, then follow Geometry: three items on the path. The folder names are the items, and “contains” is the relationship joining parent to child.

The sideways-list trap

People often treat a tree like an ordinary list because both hold many items. That is reasonable when you are only looking at the names. But a tree’s important information is who belongs under whom; flattening the names can lose the path, the levels, and the meaning of the relationship.

Trees outside lessons

Your computer’s folders use a tree, as do website menus with submenus. Games can use trees for possible moves, and a family-history tool can arrange ancestors by generations. Trees are not the right shape for every connection: a friendship network, where one person may link to many unrelated people, is better shown as a graph.

Keep exploring

Other languages

Loading MyLeoNes™…