# Chapter 7: Time Complexity

## Chapter 7.2, The Class P

### Key Ideas

• All reasonable deterministic computational models are polynomially equivalent.
• In this section, polynomial differences in algorithm implementations are ignored.
• Definition: P is the class of languages that are decidable in polynomial time on a deterministic single-tape Turing Machine.
In other words, P = ∪k TIME(nk).

### Examples of P Problems

• PATH = {<G, s, t> | G is a directed graph that has a directed path from s to t.}. A sample algorithm appears on page 288.
• RELPRIME = {<x, y> | x and y are relatively prime} A sample algorithm appears on page 289.
• ACFG = {<G, w> | G is a context-free grammar that generates string w}. A sample algorithm appears on page 291.

### Active Learning

Show the dynamic programming table that might result from testing whether the following CFG generates she programs the robot with a friend.

• S → NP VP
• VP → VP PP | V NP | programs
• PP → P NP
• NP → DET N | he | she
• DET → a | the
• N → robot | friend
• V → programs
• P → with