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

Notes: Monday 11 February 2002
Schedule

Notes

Link to All Code

(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 null-coffee if there are no coffees on the menu
   (make-coffee "null-coffee" 0.00 -1))) 
   
;;; Alternate definition:
(define (find-most-caff menu)
  (if (null? menu)
      (make-coffee "null-coffee" 0.00 -1)
      (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)
  (insertlg
   (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))

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?







CS 655 University of Virginia
Department of Computer Science
CS 200: Computer Science
David Evans
evans@virginia.edu
Using these Materials