Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decision trees Polynomial-Time

Similar presentations


Presentation on theme: "Decision trees Polynomial-Time"— Presentation transcript:

1 Decision trees Polynomial-Time
Lower Bounds Decision trees Polynomial-Time

2 Decision trees Some algorithms do not use the internal structure of their input data a1, …, an and can only compare them using <, >, or =. Any algorithm A which branches only on this information has as its execution model, for each n, a decision tree in which: Each internal node is a comparison (ai : aj), 1 ≤ i, j ≤ n. Each leaf is an outcome which answers the problem. For any particular input, execution of A corresponds to tracing a path from the root to a leaf (i.e. a branch, B) which takes time Ω(|B|). p. 340

3 Lower Bounds for Sorting
Theorem: Any decision tree that correctly orders any n elements has height Ω(n log n) in the worst-case. Proof: A correct sorting algorithm yields a permutation π(1), …, π(n) for which aπ(1) ≤ … ≤ aπ(n). With distinct keys, every comparison yields at most one bit of information, so the branching factor is two. Since there are n! different arrangements of the input, the decision tree must have at least n! different outcomes (leaves). Any binary tree of height h has ≤ 2h leaves, so n! ≤ 2h, which means log2 n! ≤ h. Now since log2 n! = log2 n + … + log2 (n/2) + … > (n/2)(log2 n − 1), h is (n log n).

4 Lower Bounds for Searching
Theorem: Any decision tree that finds a key a among n sorted elements has height Ω(log n) in the worst-case. Proof: A correct searching algorithm yields either a position 1 ≤ k ≤ n such that the a = ak, or else zero. So there must be more than n different outcomes (leaves in the decision tree). Every comparison with a has at most three possibilities (=, <, >), so the branching factor is three. Any ternary tree of height h has ≤ 3h leaves, so n < 3h, which means log3 n < h. Hence, h is (log n).

5 Polynomial-Time algorithms
For an input of size n, a running time of O(nk) for some k. Decision problems: executing algorithm YES instance of problem binary encoding machine NO abstract model By asking for individual bits in the output, we can convert any polytime algorithm with output to a polytime decision problem. Def: Let P = the class of all decision problems solvable in polynomial time. 11.3

6 Polynomial-Time Verification
Example: A Hamiltonian cycle of an undirected graph G = V, E is a simple cycle (of edges) containing each vertex (once). Problem: Does G have a Hamiltonian cycle? Verification: () certificate YES verifier G NO Yet, a purported Hamiltonian cycle can be verified in P. 11.3

7 Polynomial-Time Verification
Def: Let NP = the class of decision problems than can be verified in P. Consider a polytime preducate A(x, y): L  NP  L = {x  {0, 1}* : y A(x, y) = YES} L  co-NP  L = {x  {0, 1}* : y A(x, y) = YES}  L = {x  {0, 1}* : y A(x, y) = NO} dicuss the psychology of creating vs. verifying ideas (proofs) co-NP NP P 11.3


Download ppt "Decision trees Polynomial-Time"

Similar presentations


Ads by Google