A singly linked list node contains two fields: class ListNode: val: integer next: ListNode or null The val field stores the data.
The next field points to the following node, or null if you've reached the last node. To traverse a list, start at the head and follow next pointers until you hit null.
The operation takes time where is the list length. Memory layout differs from arrays. Array elements sit in contiguous memory, enabling cache-friendly access.
Linked list nodes scatter across memory, causing more cache misses. That's why arrays are faster for sequential access despite both being . Time: . Space: .