front insertion

Adding an item at the start of a sequence rather than the end.

In more detail

On a Python list, list.insert(0, x) shifts every existing element one slot right, so it costs O(n) and a loop of them costs O(n^2). A linked list or deque adds at the front in O(1). This single operation is often what decides between list and deque.

Related terms

Taught in

References