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

Notes: Friday 15 February 2002
Schedule

Link to All Code: http://www.cs.virginia.edu/cs200/notes/universe.ss

Quick Sort
(define (filter f lst)
  (insertlg
   (lambda (el rest) (if (f el) (cons el rest) rest))
   lst null))

(define (quicksort cf lst)
  (if (null? lst) lst
      (append 
       (quicksort cf 
		  (filter (lambda (el) (cf el (car lst))) (cdr lst)))
       (list (car lst))
       (quicksort cf 
		  (filter (lambda (el) (not (cf el (car lst)))) (cdr lst))))))
Secrets of the Universe
(define (computing-power nyears)
  (if (= nyears 0) 1 (* 1.587 (computing-power (- nyears 1)))))
  ;;; doubling every 18 months = ~1.587 * every 12 months

(define (simulation-work scale)
  (* scale scale scale)) ; Simulation is O(n^3) work

(define (log10 x) (/ (log x) (log 10))) ;; primitive log is natural (base e)

(define (knowledge-of-universe scale) (log10 scale))

(define (find-knowledge-of-universe nyears)
  ;;; Size of simulation that can execute in nyears
  (define (find-biggest-scale scale)
    (if (> (/ (simulation-work scale) 1000) ; we can simulate size 10 universe today
           (computing-power nyears))
        (- scale 1)
        (find-biggest-scale (+ scale 1))))
  (knowledge-of-universe (find-biggest-scale 1)))
Golden Ages

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