liveBook · Manning

Sequential access

As explained in Grokking Algorithms, Second Edition

Sequential access is an access pattern that retrieves elements in order by traversing from the beginning of a sequence.

Imagine reading a list from top to bottom. Sequential access retrieves elements one by one, beginning with the first element and following the sequence. section 2.8

Finding the tenth item

To read the tenth element of a linked list, you must read the first nine elements and follow each link. You cannot jump directly to item ten. section 2.8

Compare sequential access with random access:

  • Linked lists provide sequential access only because each item reveals where the next item is. section 2.8
  • Arrays provide random access, so they can jump directly to a position. section 2.8
  • Arrays can also make sequential reads faster by reading a whole nearby section at once; linked lists cannot use that approach. section 2.8

How Grokking Algorithms, Second Edition covers it

How deep it goes
Defines traversal and illustrates it with a tenth-element lookup, stopping short of implementation details.
Examples
Uses reading a linked list’s tenth element and comparing array and linked-list reads.
What you can do after
Evaluate whether arrays or linked lists better fit workloads requiring sequential or direct reads.
How it connects
Connects sequential access with random access, arrays, linked lists, reads, and caching.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Algorithms, Second Edition. The section links point to the parts of the book it draws on.