liveBook · Manning

Alphabet

As explained in Algorithms Every Programmer Should Know

An alphabet is a defined set of symbols from which strings are formed.

An alphabet is a defined set of symbols used to form strings. In string matching, assigning numbers to those symbols lets a hash function encode a pattern or text window. section 4.1

Table 4.2 Character mapping to numeric values
Character
Value
A
1
B
2
C
3
….
…
Z
26

The mapping assigns A the value 1 through Z the value 26, illustrating how symbols can be represented numerically. section 4.1

An alphabet in biological sequences

DNA uses A, T, C, and G; RNA uses the same bases but substitutes U for T; proteins use a 20-symbol alphabet corresponding to amino acids. section 4.2.2

Turning letters into a hash

With A=1 through Z=26, JOE hashes to 10 + 13 + 5 = 28, while ALI hashes to 1 + 12 + 9 = 22. section 4.1

How Algorithms Every Programmer Should Know covers it

How deep it goes
Illustrates symbol sets with DNA, RNA, proteins, and English letters, then demonstrates numeric character mappings for hashing.
Examples
Uses A–Z numbered 1–26, JOE and ALI hashes, and DNA, RNA, and protein symbol sets.
What you can do after
Apply character-to-number mappings to calculate hashes for patterns and text windows during Rabin–Karp searches.
How it connects
Connects alphabet mappings to Rabin–Karp, rolling hashes, string matching, and biological sequence matching.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Algorithms Every Programmer Should Know. The section links point to the parts of the book it draws on.