Strings and Languages
Strings and Languages
Strings
Definition of Alphabet
• An alphabet is defined to be a
non-empty finite set whose
members are called the
symbols of the alphabet.
Examples:
Σ1 = {0, 1}
Σ2 = {a, b, c, d, e, f, g, h, i, j, k,
l, m, n, o, p, q, r, s, t, u,
v, w, x, y, z}
Σ3 = {♠, ♣, ♥, ♦}
F93
Strings
Examples:
For example:
w= 6
w = w1w2 … wk
w = w1w2 … wk
wR = wk … w2w1
For example:
w = abcdef
wR = fedcba
Strings and Languages
• A string z is a substring of the
string w if z appears
consecutively within w.
For example:
For example:
If w = 11100101, then
some of the possible
prefixes of w are ε, 1, 11,
111, 1110, and 11100.
For example:
If w = 11100101, then
some of the possible
prefixes of w are ε, 1, 01,
101, 0101, and 00101.
Strings and Languages
Page 6 of 9
• A fundamental operation that
can be performed on strings is
concatenation.
xy = x1…xmy1…yn.
For example:
xy = stihq
Strings and Languages
Page 7 of 9
• Strings can be arranged in
lexicographic order.
The lexicographic ordering of
strings is the same as
alphabetical ordering except that
shorter strings precede longer
strings.
For example:
Given the following strings:
000, 01, 010, 011, 0, ε,
1101, 0110, and 1111.
Arranging them in
lexicographic order would
yield:
ε, 0, 01, 000, 010, 011,
0110, 1101, 1111
The lexicographic ordering of
strings depends of course on
how the individual ordering of
the elements of the alphabet is
defined.
Strings and Languages
Page 8 of 9
Languages
Definition of Language
For example: