Chapter 2. Search problems

 

“Search” is such a broad term that this entire book could be called Classic Search Problems in Python. This chapter is about core search algorithms that every programmer should know. It does not claim to be comprehensive, despite the declaratory title.

2.1. DNA search

Genes are commonly represented in computer software as a sequence of the characters A, C, G, and T. Each letter represents a nucleotide, and the combination of three nucleotides is called a codon. This is illustrated in figure 2.1. A codon codes for a specific amino acid that together with other amino acids can form a protein. A classic task in bioinformatics software is to find a particular codon within a gene.

2.1.1. Storing DNA

We can represent a nucleotide as a simple IntEnum with four cases.

2.2. Maze solving

2.3. Missionaries and cannibals

2.4. Real-world applications

2.5. Exercises