Concatenation — Definition, Formula & Examples
Concatenation is the operation of joining two sequences, strings, or lists end-to-end to form a single longer sequence. For example, concatenating "AB" and "CD" produces "ABCD".
Given two finite sequences and over some alphabet or set, the concatenation is the sequence of length .
Key Formula
Where:
- = First sequence of length m
- = Second sequence of length n
- = Resulting sequence of length m + n
How It Works
To concatenate, place the second sequence directly after the last element of the first sequence. The order matters: concatenating then usually gives a different result than concatenating then . In formal language theory, concatenation is often written with a dot () or simply by placing symbols side by side. In programming, common operators include (Python) or (SQL). The operation is associative, meaning , but it is generally not commutative.
Worked Example
Problem: Let set A = {0, 1} and consider strings x = "01" and y = "110". Find the concatenation x · y and state its length.
Step 1: Write string x followed immediately by string y.
Step 2: The length of x is 2 and the length of y is 3, so the length of the result is their sum.
Answer: The concatenation x · y = "01110", which has length 5.
Why It Matters
Concatenation is fundamental in formal language theory and automata, where you build complex strings from simpler ones to define grammars and regular expressions. In graph theory and discrete math, concatenation appears when combining paths or encoding structures as strings. It is also one of the most common operations in programming and data processing.
Common Mistakes
Mistake: Assuming concatenation is commutative (that A · B equals B · A).
Correction: Order matters. "AB" · "CD" = "ABCD", but "CD" · "AB" = "CDAB". These are different unless both strings happen to be identical or empty.
