Skip to content

Lesson 49: Follow the links

The route is in the pointers

  • In a linked list each place has a pointer to the next place. The order of the list does not depend on the order in the array.
  • head is the first place. A null pointer (here -1) means "no next place".
  • To visit every place: start at head, and repeat until the pointer is -1: visit the place, then follow its pointer.
Index names next_stop
0 Bank 4
1 Park 3
2 Shop 0
3 Home -1
4 School 1
  • head = 2: Shop → Bank → School → Park → Home.

Log in or create account

IGCSE, A-Level & AP