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

Notes: Wednesday 12 February 2002

• Now: Problem Set 3
• Friday, 14 February: Read Neil DeGrasse Tyson, Science's Endless Golden Age (handed out Monday, not available on-line). Neil DeGrasse Tyson is an astrophysicist who is director of the Rose Center for Earth and Space in New York. This short essay explains how what we know about the universe depends on orders of growth and Moore's law, and what skateboards, pierced belly buttons, and tattoos have to do with scientific progress.
• Monday, 17 February: Read these two short articles about Timothy Koogle: Yahoo! A Wahoo at the Top and 1973 Graduate Has Major Web Access. Think of one good question for Tim Koogle and email it to evans@cs.virginia.edu before 5pm Monday. Wednesday, 19 February's class will be a guest lecture by Tim Koogle, president and CEO of Yahoo! from 1995 (a four person company) to 2001 (when it served more than 200 million individuals).
• Wednesday, 19 February: Problem Set 4
• Friday, 21 February: Exam 1 out (see details below).
• Monday, 24 February, 2:00PM: Exam 1 due
• 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
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 (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))))
```