0% found this document useful (0 votes)
11 views24 pages

OCR A Level (H046-H446) Data Structures Part 1 - Linked Lists

A linked list is a foundational data structure composed of nodes and pointers, allowing for the construction of other structures like stacks and queues. It can be implemented using arrays or objects, providing flexibility in memory usage and dynamic data management. Linked lists have various applications, including operating systems, image viewers, music players, and web browsers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views24 pages

OCR A Level (H046-H446) Data Structures Part 1 - Linked Lists

A linked list is a foundational data structure composed of nodes and pointers, allowing for the construction of other structures like stacks and queues. It can be implemented using arrays or objects, providing flexibility in memory usage and dynamic data management. Linked lists have various applications, including operating systems, image viewers, music players, and web browsers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

SLR14 Data structures

• Overview of structures to store data –


Part 1: Linked lists

Teacher site: craigndave.org | Student site: student.craigndave.org | Smart revise: smartrevise.co.uk


SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What is a linked list?


• A linked list is a data structure that
provides a foundation upon which
other structures can be built, such as
stacks, queues, graphs and trees.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What is a linked list?


• A linked list is a data structure that
provides a foundation upon which
other structures can be built, such as
Node
stacks, queues, graphs and trees.

• A linked list is constructed from


nodes and pointers.
Pointer
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What is a linked list?


• A linked list is a data structure that
Start provides a foundation upon which
pointer other structures can be built, such as
Node
stacks, queues, graphs and trees.

• A linked list is constructed from


nodes and pointers.
Pointer
• A start pointer identifies the first
node.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What is a linked list?


0 • A linked list is a data structure that
Start provides a foundation upon which
pointer other structures can be built, such as
Node
stacks, queues, graphs and trees.

Data 1 Data 2 Data 3 Data null • A linked list is constructed from


nodes and pointers.
Pointer
• A start pointer identifies the first
node.

• Each node contains data and a


pointer to the next node.

• Many programming languages


support lists in addition to arrays.

• Data in lists can be stored anywhere


in memory, with pointers indicating
the address of the next item.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What is a linked list?


0 • By adding an extra pointer, nodes
Start can point to the previous and next
pointer items, known as a doubly linked list.
Node

Data 1 Data 2 Data 3 Data null


Pointer
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What is a linked list?


0 • By adding an extra pointer, nodes
Start can point to the previous and next
pointer items, known as a doubly linked list.
Node
• A circular linked list can be created
Data 1 Data 2 Data 3 Data 0 by making the last node point to the
first node.
Pointer
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What is a linked list?


0 • By adding an extra pointer, nodes
Start can point to the previous and next
pointer items, known as a doubly linked list.
Node
• A circular linked list can be created
Data 1 Data 2 Data 3 Data 0 by making the last node point to the
first node.
Pointer
• Each node in a circular linked list can
also have an additional pointer
pointing to the previous item,
creating a doubly circular linked list.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

Implementing linked lists using an array


ADDRESS DATA Pointer
• A linked list can be implemented
01 using a static array.
02
• Being static data structures, arrays
03 Ben 06
are stored contiguously in memory,
04 Dave null
RANDOM ACCESS MEMORY

requiring the use of an index register


05 Andy 03 to determine where a specific index
is in relation to a base address.
06 Craig 04
07 • Notice how the items are stored in
08 the array in contiguous order – Ben,
Dave, Andy, Craig.

• However, in the linked list, the items


5 5 are being stored alphabetically
Start because of their pointers – Andy,
pointer Ben, Craig, Dave.

Ben 6 Dave null Andy 3 Craig 4


SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

Implementing linked lists using objects


ADDRESS DATA Pointer
• While a linked list can be
01 implemented using a static array, its
02 Andy 04 true benefit becomes evident when
using object-oriented techniques.
03
04 Ben 05 • With a linked list that uses objects,
RANDOM ACCESS MEMORY

05 Craig 08 any available memory address can


be used to store data. It does not
06
need to be adjacent, as each node
07 points to the next in the structure.
08 Dave null
• The memory footprint of the data
structure is not determined at
2 compile time and can change
Start dynamically at runtime, referred to
as a dynamic data structure.
pointer

Andy 4 Ben 5 Craig 8 Dave null


SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What are the applications of a linked list?


• Linked lists can be used by:
o Operating systems managing a
processor to store process
blocks in a ready state.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What are the applications of a linked list?


• Linked lists can be used by:
o Operating systems managing a
processor to store process
blocks in a ready state.
o Image viewers to switch
between previous and next
images.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What are the applications of a linked list?


• Linked lists can be used by:
o Operating systems managing a
processor to store process
blocks in a ready state.
o Image viewers to switch
between previous and next
images.
o Music players to store tracks in
a playlist.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What are the applications of a linked list?


• Linked lists can be used by:
o Operating systems managing a
processor to store process
blocks in a ready state.
o Image viewers to switch
between previous and next
images.
o Music players to store tracks in
a playlist.
o Web browsers to navigate
backwards and forwards.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What are the applications of a linked list?


• Linked lists can be used by:
o Operating systems managing a
processor to store process
blocks in a ready state.
o Image viewers to switch
between previous and next
images.
o Music players to store tracks in
a playlist.
o Web browsers to navigate
backwards and forwards.

• Linked lists could also be used:


o For hash table collision
resolution as an overflow.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What are the applications of a linked list?


FAT • Linked lists can be used by:
o Operating systems managing a
0 processor to store process
blocks in a ready state.
o Image viewers to switch
Directory between previous and next
File 217 618 images.
o Music players to store tracks in
a playlist.
o Web browsers to navigate
backwards and forwards.
339 end of file
• Linked lists could also be used:
217 o For hash table collision
resolution as an overflow.
619 339 o Maintaining a file allocation
table of linked clusters on
secondary storage.
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

What operations can be performed on a linked list?

Add: Adds a node to the linked list

Delete: Removes a node from the linked list

Next: Moves to the next item in the list

Previous: Moves to the previous item in a doubly linked list

Traverse: A linear search through the linked list


SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

Having watched this video, you should be


able to answer the following key question.

• How do linked lists work?


SLR14 Data
structures

Essential algorithms for A Level


Computer Science

Teacher site: craigndave.org | Student site: student.craigndave.org | Smart revise: smartrevise.co.uk


SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466
SLR14 Data structures | Data structures – Part 1: Linked lists OCR H046/H466

You might also like