Linked List

A linked list is a data structure made of nodes, where each node holds a value and a reference (pointer) to the next node, forming a chain.

General Programming

Unlike an array, items are not stored side by side in memory; each node points to the next one. This makes inserting and removing items fast, but finding an item by position is slower.

Examples

Python

class Node:
    def __init__(self, value):
        self.value = value
        self.next = None

a = Node(1)
a.next = Node(2)
print(a.value, a.next.value)

Output:

1 2

See also

Back to the Dictionary