BeginnerTopic 20 of 104Software & Computing

Linked lists

Nodes with pointers allow cheap insertion and deletion.

In depth

A linked list stores nodes with data and pointers to the next (and previous) node. Insertion and deletion at a known node are O(1), but access by index is O(n) and cache locality is poor. Variants: singly, doubly and circular lists.

Key points

  • Head and tail pointers
  • Reversal in O(n)
  • Dummy nodes simplify code
Example

A music playlist with next and previous track uses a doubly linked list.

Why it matters

Linked lists allow fast insertion and removal at known positions without moving other items, which helps when data changes often.

Where this is used

  • Implementing a playlist where songs are added and removed frequently.
  • Building a free list in a memory allocator.
  • Storing a chain of events that changes order often.

Frequently asked questions

What is Linked lists?

Nodes with pointers allow cheap insertion and deletion.

Why is it important to understand linked lists?

Linked lists allow fast insertion and removal at known positions without moving other items, which helps when data changes often.

What is the trade-off with linked lists?

Access by index is slow because you must follow pointers from the start, and each node uses extra memory for the pointer.

Where are linked lists used in practice?

They appear inside operating systems, caches and language runtimes, though arrays are often faster for simple data.

How is Linked lists used in practice?

Typical applications include implementing a playlist where songs are added and removed frequently, building a free list in a memory allocator and storing a chain of events that changes order often.

What should I learn before Linked lists?

Study "Stacks and queues" first (topic 19 of 104 in Software & Computing). It covers the groundwork this topic builds on.

What are the key points of Linked lists?

Head and tail pointers. Reversal in O(n). Dummy nodes simplify code.

Can you give an example of Linked lists?

A music playlist with next and previous track uses a doubly linked list.

What comes after Linked lists?

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

How difficult is Linked lists?

It is classed as Beginner in Software & Computing (topic 20 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