Docsity

Advanced Computational Complexity-Lecture 03 Slides-Computer Science, Slides of Advanced Computational Complexity

Partial preview of the text

Download Advanced Computational Complexity-Lecture 03 Slides-Computer Science and more Slides Advanced Computational Complexity in PDF only on Docsity!

Lecture 3: The Class P

Matthew Johnson

[email protected]

Reminder From Last Week

Theorem (Linear Speed-Up) For any TM T that decides a language L, and any m > 0 there is another TM T ′^ that also decides L, such that

TimeT ′ (x) ≤ Time mT (x)+ 2 |x|.

Theorem (Table Look-Up) For any TM T that decides a language L, and any m > 0 there is another TM T ′^ that also decides L, such that for all inputs x with |x| ≤ m, TimeT (x) = |x|.

The Big–Oh Notation

Definition A function f (n) is said to be O(g(n)) if and only if there are positive constants, c and n 0 such that f (n) ≤ c · g(n) for all n > n 0.

Intuition: f grows not faster than g.

Exercise

1 3 n + 7 is O(n)? 2 n is O( 3 n + 7 )? 3 n^2 + n is O(n^2 )? 4 n^2 is O(n^2 + n)? 5 n is O( 0. 1 n^2 )? 6 0. 1 n^2 is O(n)? 7 log n is O(n)? 8 n is O(log n)? 9 nk^ is O( 2 n)? 10 2 n^ is O(nk^ )?

Exercise

1 3 n + 7 is O(n)? YES 2 n is O( 3 n + 7 )? YES 3 n^2 + n is O(n^2 )? 4 n^2 is O(n^2 + n)? 5 n is O( 0. 1 n^2 )? 6 0. 1 n^2 is O(n)? 7 log n is O(n)? 8 n is O(log n)? 9 nk^ is O( 2 n)? 10 2 n^ is O(nk^ )?

Exercise

1 3 n + 7 is O(n)? YES 2 n is O( 3 n + 7 )? YES 3 n^2 + n is O(n^2 )? YES 4 n^2 is O(n^2 + n)? 5 n is O( 0. 1 n^2 )? 6 0. 1 n^2 is O(n)? 7 log n is O(n)? 8 n is O(log n)? 9 nk^ is O( 2 n)? 10 2 n^ is O(nk^ )?

Exercise

1 3 n + 7 is O(n)? YES 2 n is O( 3 n + 7 )? YES 3 n^2 + n is O(n^2 )? YES 4 n^2 is O(n^2 + n)? YES 5 n is O( 0. 1 n^2 )? YES 6 0. 1 n^2 is O(n)? 7 log n is O(n)? 8 n is O(log n)? 9 nk^ is O( 2 n)? 10 2 n^ is O(nk^ )?

Exercise

1 3 n + 7 is O(n)? YES 2 n is O( 3 n + 7 )? YES 3 n^2 + n is O(n^2 )? YES 4 n^2 is O(n^2 + n)? YES 5 n is O( 0. 1 n^2 )? YES 6 0. 1 n^2 is O(n)? NO 7 log n is O(n)? 8 n is O(log n)? 9 nk^ is O( 2 n)? 10 2 n^ is O(nk^ )?

Exercise

1 3 n + 7 is O(n)? YES 2 n is O( 3 n + 7 )? YES 3 n^2 + n is O(n^2 )? YES 4 n^2 is O(n^2 + n)? YES 5 n is O( 0. 1 n^2 )? YES 6 0. 1 n^2 is O(n)? NO 7 log n is O(n)? YES 8 n is O(log n)? NO 9 nk^ is O( 2 n)? 10 2 n^ is O(nk^ )?

Exercise

1 3 n + 7 is O(n)? YES 2 n is O( 3 n + 7 )? YES 3 n^2 + n is O(n^2 )? YES 4 n^2 is O(n^2 + n)? YES 5 n is O( 0. 1 n^2 )? YES 6 0. 1 n^2 is O(n)? NO 7 log n is O(n)? YES 8 n is O(log n)? NO 9 nk^ is O( 2 n)? YES 10 2 n^ is O(nk^ )?

Exercise

1 3 n + 7 is O(n)? YES 2 n is O( 3 n + 7 )? YES 3 n^2 + n is O(n^2 )? YES 4 n^2 is O(n^2 + n)? YES 5 n is O( 0. 1 n^2 )? YES 6 0. 1 n^2 is O(n)? NO 7 log n is O(n)? YES 8 n is O(log n)? NO 9 nk^ is O( 2 n)? YES 10 2 n^ is O(nk^ )? NO Question: compare growth rate of log 2 n and log 999 n.

Time Complexity

Definition For any function f , we say that the time complexity of a decidable language L is O(f ), or L is decidable in O(f ) time, if there exists a TM T which decides L, and constants n 0 and c such that for all inputs x with |x| > n 0 ,

TimeT (x) ≤ cf (|x|)

Examples

The Class P

Definition

P =

k≥ 0

TIME[nk^ ]

Note: The class P contains all classes TIME[t(n)], where t(n) is a polynomial of finite degree