CS200: Computer Science, Spring 2003
|
Notes: Monday 10 February 2002
Schedule
- Wednesday, 12 February: Problem Set 3
- Friday, 14 February: Read Neil DeGrasse Tyson, Science's Endless Golden Age (not available on-line)
- Before 10 March: Read rest of GEB part I (Chapters 2-4 and 6-9, in addition to Chapters 1 and 5 you have already read).
Notes
How do computer scientists measure work?(define (find-most-caffeinated menu) (insertlg (lambda (c1 c2) (if (> (coffee-caffeine-rating c1) (coffee-caffeine-rating c2)) c1 c2)) menu ;; we should only get the water if there are no coffees on the menu (make-coffee "water" 0.00 0))) ;;; Alternate definition: (define (find-most-caff menu) (if (null? menu) (make-coffee "water" 0.00 0) (let ((rest-most-caff (find-most-caff (cdr menu)))) (if (> (coffee-caffeine-rating (car menu)) (coffee-caffeine-rating rest-most-caff)) (car menu) rest-most-caff)))) ;;; Evaluates to the list parameter with exactly one instance of el removed. (define (delete lst el) (if (null? lst) (error "Element not found!") (if (eq? (car lst) el) ) ) ) (define (sort-menu menu) (if (null? menu) menu (let ((most-caff (find-most-caffeinated menu))) (cons most-caff (sort-menu (delete menu most-caff)))))) (define (find-most cf lst) (insertl (lambda (c1 c2) ( )) lst (car lst))) (define (sort cf lst) (if (null? lst) lst (let ((most (find-most cf lst))) (cons ) ) ) ) (define (sort-menu-by-price menu) (sort (lambda (c1 c2) (> (coffee-price c1) (coffee-price c2))) menu))
If bubblesort has expected work Θ(n2) and quicksort has expected work Θ(n log2 n) which is faster? (Hint: trick question)
If bubblesort has expected work Θ(n2) and it takes 5 seconds to sort a list of length 1000, how long would you expect it to take to sort a list of length 4000?
Assuming Moore's Law continues to hold (computing power per dollar doubles every 18 months), if the longest list we can use bubblesort to sort today is length 6000, how long a list should we be able to sort using the same code on the new lab machines in 2006?
Needed Here |
|
cs200-staff@cs.virginia.edu Using these Materials |