How does a linked list keep its items in order?
Each node holds a pointer to the next node, like a treasure hunt of clues.
- Each node points to the next node ✔
- Items sit side by side in one block of memory
- A hash function sorts them
Why: A linked list stores each item in its own node, and each node holds the address of the next one. You can insert by relinking pointers, but reaching item number 500 means walking 500 links.
Huh, didn't know that: Getting the i-th item is O(1) in an array but O(n) in a linked list, the classic trade-off between the two.
My linked list broke up with me. It said I was not pointing in the right direction.
References
Answer: Each node points to the next node. A linked list stores each item in its own node, and each node holds the address of the next one. You can insert by relinking pointers, but reaching item number 500 means walking 500 links.
- MIT 6.006 Introduction to Algorithms, Lecture 2: Data Structures ocw.mit.edu/courses/6-006-introduction-to-algorithms-spring-2020/resources/mit6_006s20_lec2
Each item stored in a node which contains a pointer to the next node in sequence
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.