Passer au contenu

Lesson 76: Linked list

English

Pointers give the order

  • A linked list keeps items in any free place in an array. Each node stores its data and a pointer: the index of the next node.
  • headPointer gives the first node. A null pointer (here 0) means "this is the last node".
  • To add or remove an item, you change pointers. No item has to move.
Index data pointer
1 Bridge 3
2 Station 1
3 Market 4
4 Park 0
  • headPointer = 2, so the route is Station → Bridge → Market → Park.

A linked list: headPointer is 2, so the list starts at index 2, Station, whose pointer 1 leads to Bridge; Bridge points to 3, Market; Market points to 4, Park; Park's pointer is 0, the null pointer, so the list ends

Se connecter ou créer un compte

IGCSE, A-Level & AP