1.4 Data Types, Data Structures and Boolean Algebra
1.4.1 – Data Structures
Linked Lists
Learning Objectives
Explore - I show a good understanding of the above data structures
(Grade U to D)
Enhance - I show a good understanding of the above data structures and can write pseudocode algorithms to meet requirements with a queue. (Grade C to B)
Excel - I evidence a clear understanding of the above data structures and can implement a linked list.
(Grade A* to B)
List
Adding to a list
Bill | Emily | Sarah | Ken | Hayley | |
Bill | Emily | | Sarah | Ken | Hayley |
Items are moved up in the array to make space for new item
Bill | Emily | Daniel | Sarah | Ken | Hayley |
New item is inserted.
Deleting items is the same process in reverse. Item is deleted and other items moved to fill the gap
Linked Lists
Linked Lists
Array Index | Name | Pointer |
0 | | 1 |
1 | | 2 |
2 | | 3 |
3 | | 4 |
4 | | 5 |
5 | | null |
start = null
nextFree = 0
A pointer named start is set to null – to show that the list is empty. When the list is populated with data, the start variable will change to 0.
The nextFree variable is set to 0 to state that the next available array index is 0.
Linked Lists
start = 0
nextFree = 4
The start pointer points to 0 – the first item in the list.
The nextFree variable is set to 0 to state that the next available array index is 0.
Array Index | Name | Pointer |
0 | Browning | 3 |
1 | Turner | null |
2 | Johnson | 1 |
3 | Cray | 2 |
4 | | 5 |
5 | | null |
Inserting an item
Array Index | Name | Pointer |
0 | Browning | 3 |
1 | Turner | null |
2 | Johnson | 4 |
3 | Cray | 2 |
4 | Mortimer | 1 |
5 | | null |
start = 0
nextFree = 5
Pseudocode
Pseudocode
newName = input(“Enter name”)
Names[nextfree].name = newName
P = start
#follow pointers until names[p].pointer
#points to a name that is > new name
Temp = nextfree
Nextfree = Names[temp].pointer
Names[temp].pointer = Names[p].pointer
Names[p].pointer = temp