teach-ict.com logo

THE education site for computer science and ICT

2. List

When data items (also called elements or nodes) are related to one another, they can be organised as a list.

For example, a collection of 11 names that seem to be random, one of which is Wayne Rooney. I suspect that 11 names with Wayne Rooney is probably a football team.

So it makes sense to collate those names into a group called 'football_team' or perhaps a specific real team.

A list is created because those 11 people are not random, they are related in some formally agreed way.

This pattern of relationship is almost universal and so a list is the most basic data structure from which flows much more complicated structures (array,stack,queue,tree,graph) - but in the end, they are all just a type of list.

Each element in the list is stored in memory, one after the other.

list in memory

Ordered List

The collection of every English letter creates a list known as the English alphabet and of course there are 26 items in it. The alphabet is an example of an ordered list, where every element is in its logical position according to some rule.

Ordered lists may be in ascending or descending order, time order etc.

Unordered list

Unordered lists do not have any rules about where a particular element is located within the list. The position of elements is down to when they were added to the list.

For example, an online shopping cart where you can continue to add (or delete) items. Each item will be placed sequentially after the last item - there is no particular order to the items in the list.

List actions

There are a number of standard actions or processing that can be carried out on a list (this includes all other specialist types of list such as array,queue,stack,tree,graph - substitute the word 'list' as appropriate.). These include

  • Creating list
  • Deleting list
  • Appending to list
  • Inserting into list
  • Removing from list
  • Search a list
  • Sort a list
  • Iterating through a list

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 list in programming?