Linked Lists

Home > Computer Science > Algorithms and data structures > Linked Lists

This is a data structure in which each element points to the next in a chain, allowing for dynamic size and rearrangement.

"In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next."
"In its most basic form, each node contains data, and a reference (in other words, a link) to the next node in the sequence."
"The principal benefit of a linked list over a conventional array is that the list elements can be easily inserted or removed without reallocation or reorganization of the entire structure."
"They can be used to implement several other common abstract data types, including lists, stacks, queues, associative arrays, and S-expressions."
"A drawback of linked lists is that data access time is a linear function of the number of nodes for each linked list because nodes are serially linked, so a node needs to be accessed first to access the next node."
"More complex variants add additional links, allowing more efficient insertion or removal of nodes at arbitrary positions."
"Arrays have better cache locality compared to linked lists."
"On the other hand, since simple linked lists by themselves do not allow random access to the data or any form of efficient indexing..."
"...it is not uncommon to implement those data structures directly without using a linked list as the basis."
"Linked lists allow insertion and removal of nodes at any point in the list, and allow doing so with a constant number of operations by keeping the link previous to the link being added or removed in memory during list traversal."
"Obtaining the last node of the list... may require iterating through most or all of the list elements."
"It is a data structure consisting of a collection of nodes which together represent a sequence."
"Each element points to the next."
"A reference (in other words, a link) to the next node in the sequence."
"Data access time is a linear function of the number of nodes for each linked list."
"The list elements can be easily inserted or removed without reallocation or reorganization of the entire structure."
"Restructuring an array at run-time is a much more expensive operation."
"Simple linked lists by themselves do not allow... any form of efficient indexing."
"More complex variants add additional links, allowing more efficient insertion or removal of nodes at arbitrary positions."
"Keeping the link previous to the link being added or removed in memory during list traversal."