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

Notes: Wednesday 12 February 2002
Schedule

Notes
Grounds Sort
(define (sort cf lst)
  (if (null? lst) lst
      (let ((most (find-most cf lst)))
        (cons most (sort cf (delete lst most))))))

;;; 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)
          (cdr lst)
          (cons (car lst) (delete (cdr lst) el)))))

(define (find-most cf lst)
  (insertl
   (lambda (c1 c2) (if (cf c1 c2) c1 c2))
   lst
   (car lst)))
Insert Sort
(define (insertsort cf lst)
  (if (null? lst) null
      (insertel cf (car lst) (insertsort cf (cdr lst)))))

(define (insertel cf el lst)
  (if (null? lst) (list el)
      (if (cf el (car lst))
	  (cons el lst)
	  (cons (car lst) (insertel cf el (cdr lst))))))
Measuring Work

How do computer scientists measure work?








If groundsort 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?




Exam 1

Exam 1 will be handed out on Friday, 21 February and due on Monday 24 February. There will not be a time limit, but for a well-prepared student it should only take a couple hours. It will be open book and open notes.

It covers everything in the course up to and including Monday, 17 February's class. Although it may ask questions about anything you have seen in the readings, lectures and problem sets, students who deeply understand the material covered on the problems sets and the notes handouts will do well on the exam.

Exam 1 from last year's course is attached. Your Exam 1 will be quite similar in format and content (but of course, the questions will be different!). You are encouraged to try and solve these problems on your own, and then to discuss them with your classmates. After that, you may look at the answers on the web.

The insertlg procedure mentioned in question 6 is similar to the insertl procedure you have seen:

(define (insertlg f lst start)
  (if (null? lst) 
      start
      (f (car lst) (insertlg f (cdr lst) start))))

Links

The progress of invention and discovery of improvement and application is so rapid,
unceasing and continuous, that it would require a volume many times the size of the present,
to record, even in a summary fashion, all that transpires of scientific interest in the course of a single year.

David A. Wells, Annual of Scientific Discovery, 1852. (Quoted in Neil DeGrasse Tyson's essay.)

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