Resource · Guide or article
Linked List Traversal
States the most basic linked list task, walking the nodes from head to tail, using a three-node list as the example. Suited to beginners checking they can move a pointer through a list.
Reviewed
Open the original: Linked List Traversal (opens the original site in a new tab)Practice this topicOpens the practice interviewer in Technical / coding mode; choose a question there.
Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
Read this in other languages: Русский, 中文, Português The task is to traverse the given linked list in straight order. For example for the following linked list:
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Reference
What it covers
- Expected forward output 12, 99, 37 for the pictured singly linked list
- O(n) time, with each node visited once
How to use it
PrepKit study advice, not a claim made by the source.
Walk the list with one pointer, then reuse the loop to find the length and the middle node.
Scope and limitations
A task statement with one example and no further explanation, code walkthrough or edge cases such as an empty list. Further reading is one Wikipedia link.
Access and format
Free English README on GitHub in the MIT-licensed trekhleb/javascript-algorithms repository.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/linked-list/traversal/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.