4.2.2

Linked List

Test yourself

Linked List

Linked lists are commonly used data structures with benefits of flexibility and ease of use. They can be used to implement other data structures such as stacks and queues.

Illustrative background for Linked listIllustrative background for Linked list ?? "content

Linked list

  • Linked lists consist of nodes.
  • Each node contains a data item and a pointer to the next node in the sequence.
  • A null pointer is used to identify the last item of data.
  • The use of pointers means that unlike arrays, data in linked lists do not have to be stored contiguously in memory.
  • They are also referred to as being ‘dynamic’ in that they can grow or shrink in size as and when necessary.
Illustrative background for ExampleIllustrative background for Example ?? "content

Example

  • The diagram shown is graphical representation of a linked list containing the names of three animals in alphabetical order.
Illustrative background for Adding nodesIllustrative background for Adding nodes ?? "content

Adding nodes

  • To add ‘Tiger’ to the list alphabetically, the pointer of node 1 is updated to point to the new node, which in turn points to the next in the sequence (node 2).
Illustrative background for Deleting nodesIllustrative background for Deleting nodes ?? "content

Deleting nodes

  • To delete ‘Rhino’ from the list, the pointer of node 0 is updated to point to node 3.
  • The data of node 1 is deleted.
  • This node becomes the first of a separate list of empty nodes, ready to be filled again.

Jump to other topics

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Ahead

6.3Thinking Procedurally

6.4Thinking Logically

6.5Thinking Concurrently

7Problem Solving & Programming

8Algorithms

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium