teach-ict.com logo

THE education site for computer science and ICT

2. Trees

A 'tree' is a basic data structure in computing. It links a number of data elements together in a hierarchy, from top to bottom. A general tree structure is shown below

Tree data structure

Each element in the tree is called a 'node' and each link is called a 'branch'. The node at the top of the tree is called the 'root node' and each node below it is called a 'leaf node'.

Alternatively, instead of roots and leaves, you may also hear nodes described as 'parent' nodes and 'child' nodes.

Just like a family tree, the parents are placed at a higher level, above the children. In the example above, if we look at 'Item B', then its 'parent' node is 'Item A' and its 'child' nodes are Items E, D and C.

Why does this matter? Well, in computing terms, each node records the memory locations of all of the nodes to which it is connected, i.e. the parent and child nodes.

The way that trees are organised allows for very efficient sorting, searching and managing of data.

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: What is a tree data structure