CS200: Computer Science, Spring 2003

Notes: Wednesday 19 March 2003
Schedule
 Today: Read GEB, Aria with Diverse Variations and Chapter 13. This chapter proves that the halting problem is not decidable, and introduces the ChurchTuring Thesis (which we will explore more in Classes 3236). You will not be assigned to read Chapter XIV, but it goes into more depth on Gödel's proof and it recommended.
 Monday, 24 March: Problem Set 6.
Upcoming lab hours: Wednesday, 19 March: 89:30 PM (Jacques)
Thursday, 20 March: 89:30 PM (Jacques)
Sunday, 23 March: 12:30 PM (Katie)
Sunday, 23 March: 23:30 PM (Rachel)
 Monday, 31 March: Problem Set 8 team requests (see Notes 21 for details)
Permute Sort (define (flatone lst) (if (null? lst) lst (append (car lst) (flatone (cdr lst))))) (define (allpermutations lst) (flatone (map (lambda (n) (if (= (length lst) 1) (list lst) ;; Only one permutation of 1length list (map (lambda (oneperm) (cons (nth lst n) oneperm)) (allpermutations (exceptnth lst n))))) (intsto (length lst))))) (define (issorted? cf lst) (or (null? lst) (= 1 (length lst)) (and (cf (car lst) (cadr lst)) (issorted? cf (cdr lst))))) (define (permutesort cf lst) (car (filter (lambda (lst) (issorted? cf lst)) (allpermutations lst))))Notes How much work is permutesort?
What is a problem?
Upper bound O ("bigoh"): f(x) is O (g (x)) means there is a positive constant c such that c * f(x) < g(x) for all but a finite number of x values.
Lower bound Ω ("omega"): f(x) is Ω (g (x)) means there is a positive constant c such that c * f(x) > g(x) for all but a finite number of x values.
 x^{2} is O (x^{2}) — c = .5 works fine
 x^{2} is O (x^{3}) — c = 1 works fine
 x^{3} is not O (x^{2}) — for any choice of c, once x gets big enough c * x^{3} > x^{2}
 Time to do bubblesort for a list of length n is O (n^{2}) — the value of c depends on how fast our computer is
 Time to solve the pegboard puzzle with n pegs is O (2^{n}) — we know how to solve it in c * 2^{n} time for some constant c by trying all possible moves (assuming 2 possible moves at each step).
 Time to pegboard puzzle might or might not be O (n) — we don't know of an O (n) procedure to solve it, but we have not proven one does not exist either.
Tight bound Θ ("theta"): f(x) is Θ (g (x)) means that f(x) is O(g (x)) and f(x) is Ω (g (x)).
 x^{2} is Ω (x^{2}) — c = 2 works fine
 x^{2} is not Ω (x^{3}) — for any choice of c, once x gets big enough c * x^{2} < x^{3}
 x^{3} is Ω (x^{2}) — for any choice of c, once x gets big enough c * x^{3} > x^{2}
 Time to do bubblesort for a list of length n is Ω (n^{2}) — the value of c depends on how fast our computer is.
 Time to solve pegboard puzzle with n pegs is might be or might not be Ω (2^{n}) — we don't know if there is a solution to the pegboard puzzle that is faster than c * 2^{n}.
 Time to solve pegboard puzzle is Ω (n) — we do know that there is no solution to the pegboard puzzle that is faster than c * n since any solution involves at least as many moves as their are pegs.
What does it really mean to say a problem is O (n^{2})?
 x^{2} is Θ (x^{2}) since x^{2} is O (x^{2}) and x^{2} is Ω (x^{2}).
 x^{2} is not Θ (x^{3}) since x^{2} is not Ω (x^{3})
 x^{3} is not Θ (x^{2}) since x^{3} is not O (x^{2})
 Time to do bubblesort for a list of length n is Θ (n^{2}) since it is O (n^{2}) and Ω (n^{2})
 Time to solve pegboard puzzle with n pegs might or might not be Θ (2^{n}) since it is O (2^{n}) but we don't know if it is Ω (2^{n}) .
 Time to solve pegboard puzzle might or might not be Θ (n) since it is Ω (n) but we don't know it it is O (n) but have not proven it cannot be O (n).
What does it really mean to say a problem is Ω (n^{2})?
What does it mean to say a problem is in complexity class P?
What does it mean to say a problem is in complexity class NP?
Are all problems in P also in NP?
Are all problems in NP also in P?
Note: this is the Millennium Prize Problem: The P versus NP Problem. Clay Mathematics Institute will give you $1M if you answer it, so you may to use the margins to answer it.

cs200staff@cs.virginia.edu Using these Materials 