University of Virginia, Department of Computer Science
CS200: Computer Science, Spring 2003

Notes: Wednesday 19 March 2003
Schedule

Permute Sort
(define (flat-one lst)
  (if (null? lst) lst (append (car lst) (flat-one (cdr lst)))))

(define (all-permutations lst)
  (flat-one
   (map
    (lambda (n)
      (if (= (length lst) 1)
          (list lst) ;; Only one permutation of 1-length list
          (map 
           (lambda (oneperm) (cons (nth lst n) oneperm))
           (all-permutations (exceptnth lst n)))))
    (intsto (length lst)))))

(define (is-sorted? cf lst)
  (or (null? lst) (= 1 (length lst)) 
      (and (cf (car lst) (cadr lst))
           (is-sorted? cf (cdr lst)))))

(define (permute-sort cf lst)
  (car 
   (filter (lambda (lst) (is-sorted? cf lst)) 
           (all-permutations lst))))
Notes

How much work is permute-sort?



What is a problem?



Upper bound O ("big-oh"): 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. Tight bound Θ ("theta"): f(x) is Θ (g (x)) means that f(x) is O(g (x)) and f(x) is Ω (g (x)). What does it really mean to say a problem is O (n2)?


What does it really mean to say a problem is Ω (n2)?


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.

CS 200


CS 200: Computer Science
Department of Computer Science
University of Virginia

Circle Fractal by Ramsey Arnaoot and Qi Wang

cs200-staff@cs.virginia.edu
Using these Materials