CS200: Computer Science, Spring 2002
|
Notes: Wednesday 13 February 2002
Schedule Optional Reading: Neil DeGrasse Tyson, Science's Endless Golden Age. From The Invisible Future, McGraw Hill, 2002.
- Now: Problem Set 3
- Today's office hours are rescheduled for Friday after class (send email to arrange another time if that is bad)
- Friday, 22 February: Problem Set 4
- Before 18 March: GEB all of Part I
- Monday, 25 February: Exam 1 Out (will be take-home, shouldn't take more than a few hours, but there will be no time limit)
- Wednesday, 27 February: Exam 1 Due
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.Link to All Code: http://www.cs.virginia.edu/cs200/notes/sorting.ss
Bubble Sort (define (insertlg f lst start) (if (null? lst) start (f (car lst) (insertlg f (cdr lst) start)))) ;;; 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) (insertlg (lambda (c1 c2) (if (cf c1 c2) c1 c2)) lst (car lst))) (define (bubblesort cf lst) (if (null? lst) lst (let ((most (find-most cf lst))) (cons most (bubblesort cf (delete lst most))))))Insert Sort (define (insertel cf el lst) (if (null? lst) (list el) (if (cf el (car lst)) | | | | | | ))) (define (insertsort cf lst) (if (null? lst) null (insertel cf (car lst) | | | )))Quick Sort (define (filter f lst) (insertlg | | | lst null)) (define (quicksort cf lst) (if (null? lst) lst (append | | | (list (car lst)) | | | ) ) )Sorting Demos Based on James Gosling's Java implementation from http://www.cs.rit.edu/~atk/Java/Sorting/sorting.html. (View on-line notes.)
Bubble Sort Quick Sort 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.)
University of Virginia Department of Computer Science CS 200: Computer Science |
David Evans evans@virginia.edu Using these Materials |