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

Notes: Monday 10 February 2002

• 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

```(define (find-most-caffeinated menu)
(insertlg
(lambda (c1 c2)
(if (> (coffee-caffeine-rating c1)
(coffee-caffeine-rating c2))
c1
c2))
;; we should only get the water if there are no coffees on the menu
(make-coffee "water" 0.00 0)))

;;; Alternate definition:
(make-coffee "water" 0.00 0)
(coffee-caffeine-rating rest-most-caff))
rest-most-caff))))

;;; Evaluates to the list parameter with exactly one instance of el removed.
(define (delete lst el)
(if (eq? (car lst) el)

)
)
)

(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

)
)
)
)

(sort (lambda (c1 c2) (> (coffee-price c1) (coffee-price c2))) menu))

```
How do computer scientists measure work?

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?