§ 02 — Data Structures and Algorithms
A linked list can be represented using arrays. This approach is sometimes called an array implementation of a linked list or a cursor-based linked list.
Instead of using actual memory pointers, the structure uses indexes.
Two parallel arrays are commonly used:
| Array | Purpose |
|---|---|
key | Stores the actual data value. |
next | Stores the index of the next item in the list. |
A special index such as head marks the start of the list. Another special marker may represent the end of the list.
For example:
next[head] = 4
key[4] = "A"
next[4] = 3
key[3] = "L"
This means the first item after head is stored at index 4, and that item contains A. The next item is at index 3, containing L.
Array-based linked lists help students understand how links work without using actual pointer syntax. They also show that the logical order of a list does not need to match the physical order of values in storage.
Suppose the list uses these records:
| Index | Key | Next |
|---|---|---|
| 0 | HEAD | 4 |
| 4 | A | 3 |
| 3 | L | 2 |
| 2 | I | 6 |
| 6 | S | 1 |
| 1 | TAIL | 1 |
Starting from HEAD, follow the next values:
HEAD -> A -> L -> I -> S -> TAIL
The list order is based on links, not on index order.
Pro2 reviewers locked
Part of this subject's paid reviewers. Not included in this printout.
Done with this module? Track it — your progress shows on the subject list.
Studying with blockmates? Send them this lesson.
Up next
Lesson 5: Stack Data Structure→←Previous: Lesson 3: Arrays and Linked Lists