Home

prepending

Prepending is the act of placing an item or sequence at the beginning of another sequence. In computing and data processing, prepending means creating a new structure by inserting at the front rather than at the end. The opposite operation is appending, which adds to the tail.

In linguistics, prepending can refer to prefixation, the attachment of a morpheme to the start of a

In data structures, prepending has different cost profiles. For example, adding an element to the front of

Within programming languages, various idioms embody prepending: in Lisp, the cons operation constructs a new list

word
to
modify
its
meaning
or
grammatical
category.
The
term
is
also
used
more
broadly
to
describe
artificial
or
stylistic
additions
placed
before
a
base
form
in
text
processing.
a
singly
linked
list
is
typically
O(1),
since
it
involves
creating
a
new
node
that
points
to
the
current
first
element.
In
contrast,
prepending
to
an
array
requires
shifting
all
existing
elements
and
is
usually
O(n).
Some
structures,
such
as
deques,
support
fast
prepend
via
dedicated
operations.
by
placing
an
element
at
the
head;
in
Haskell,
the
colon
operator
does
the
same;
in
Python,
prepend-like
behavior
can
be
achieved
with
[x]
+
lst
or
using
insert(0,
x),
which
is
O(n).
Understanding
the
performance
characteristics
helps
guide
data-structure
choice
and
algorithm
design.