BeginnerTopic 8 of 104Software & Computing

Arrays and lists

Ordered collections accessed by index.

In depth

Arrays store elements contiguously with O(1) index access; dynamic lists grow automatically. Operations: append, insert, delete, slice, sort, search. Multi-dimensional arrays represent matrices and images. Out-of-range indexing is a classic bug.

Key points

  • Zero-based indexing
  • Insertion in the middle is O(n)
  • Cache-friendly
Example

a=[3,1,2]; a.sort() yields [1,2,3].

Why it matters

Arrays and lists store collections of values accessed by position, which is the basis of most data handling.

Where this is used

  • Storing a day of temperature readings for plotting.
  • Keeping a queue of tasks for a worker.
  • Holding the coordinates of points for a drawing.

Frequently asked questions

What is Arrays and lists?

Ordered collections accessed by index.

Why is it important to understand arrays and lists?

Arrays and lists store collections of values accessed by position, which is the basis of most data handling.

What is the difference between an array and a list?

An array usually has a fixed size and fast indexing. A list often grows dynamically, and the implementation determines how efficient insertion is.

What is an off-by-one error?

Using an index that is one too large or small, which is common at the start or end of a sequence.

How is Arrays and lists used in practice?

Typical applications include storing a day of temperature readings for plotting, keeping a queue of tasks for a worker and holding the coordinates of points for a drawing.

What should I learn before Arrays and lists?

Study "Functions" first (topic 7 of 104 in Software & Computing). It covers the groundwork this topic builds on.

What are the key points of Arrays and lists?

Zero-based indexing. Insertion in the middle is O(n). Cache-friendly.

Can you give an example of Arrays and lists?

a=[3,1,2]; a.sort() yields [1,2,3].

What comes after Arrays and lists?

The next topic is "Strings", which builds directly on this one.

How difficult is Arrays and lists?

It is classed as Beginner in Software & Computing (topic 8 of 104). It is an entry-level topic. It relies only on basic school mathematics and the ideas introduced earlier in this discipline.

Learning path

Want to practise? Open the interactive course for quick checks, quizzes, simulations and progress tracking.

Related topics