CS200: Computer Science, Spring 2002
|
Notes: Monday 18 February 2002
Schedule Link to All Code: http://www.cs.virginia.edu/cs200/notes/permutesort.ss
- Friday, 22 February: Problem Set 4
- Monday, 25 February: Exam 1 Out (will be take-home, shouldn't take more than a few hours, but there will be no time limit; covers Lecture 1-13, Problem Sets 1-4, assigned readings through today)
- Wednesday, 27 February: Exam 1 Due
- Before 18 March: GEB all of Part I
Permute Sort How much work is 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))))
What is a problem?
What does it mean to say a problem is O (n2)?
What does it mean to say a problem is Ω (n2)?
What does it mean to say a problem is in P?
What does it mean to say a problem is in 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 need more space.
University of Virginia Department of Computer Science CS 200: Computer Science |
David Evans evans@virginia.edu Using these Materials |