lecture21

Information about lecture21

Published on June 26, 2007

Author: Funtoon

Source: authorstream.com

Content

Slide1:  David Evans http://www.cs.virginia.edu/evans Class 21: The Story So Far (Quicksort, Continuing Golden Ages) CS200: Computer Science University of Virginia Computer Science InsertSort-tree:  InsertSort-tree (define (insertel-tree cf el tree) (if (null? tree) (make-tree null el null) (if (cf el (get-element tree)) (make-tree (insertel-tree cf el (get-left tree)) (get-element tree) (get-right tree)) (make-tree (get-left tree) (get-element tree) (insertel-tree cf el (get-right tree)))))) (define (insertsort-tree cf lst) (define (insertsort-worker cf lst) (if (null? lst) null (insertel-tree cf (car lst) (insertsort-worker cf (cdr lst))))) (extract-elements (insertsort-worker cf lst))) (log n) n = number of elements in tree (n log n) n = number of elements in lst extract-elements:  extract-elements We need to make a list of all the tree elements, from left to right. (define (extract-elements tree) (if (null? tree) null (append (extract-elements (get-left tree)) (cons (get-element tree) (extract-elements (get-right tree)))))) Quicksort:  Quicksort C. A. R. (Tony) Hoare, 1962 Divide the problem into: Sorting all elements in the list where (cf (car list) el) is true (it is andlt; the first element) Sorting all elements in the list where (not (cf (car list) el) is true (it is andgt;= the first element) Will this do better? Quicksort:  Quicksort (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)))))) How much work is quicksort?:  How much work is quicksort? (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)))))) What if the input list is sorted? Worst Case: (n2) What if the input list is random? Expected: (n log2 n) Comparing sorts:  Comparing sorts andgt; (testgrowth insertsort-tree) n = 250, time = 20 n = 500, time = 80 n = 1000, time = 151 n = 2000, time = 470 n = 4000, time = 882 n = 8000, time = 1872 n = 16000, time = 9654 n = 32000, time = 31896 n = 64000, time = 63562 n = 128000, time = 165261 (4.0 1.9 3.1 1.9 2.1 5.2 3.3 2.0 2.6) andgt; (testgrowth quicksort) n = 250, time = 20 n = 500, time = 80 n = 1000, time = 91 n = 2000, time = 170 n = 4000, time = 461 n = 8000, time = 941 n = 16000, time = 2153 n = 32000, time = 5047 n = 64000, time = 16634 n = 128000, time = 35813 (4.0 1.1 1.8 2.7 2.0 2.3 2.3 3.3 2.2) Both are (n log2 n) Absolute time of quicksort much faster Good enough for VISA?:  Good enough for VISA? n = 128000, time = 35813 36 seconds to sort 128000 with quicksort (n log2 n) How long to sort 800M items? andgt; (log 4) 1.3862943611198906 andgt; (* 128000 (log 128000)) 1505252.5494914246 andgt; (/ (* 128000 (log 128000)) 36) 41812.57081920624 andgt; (/ (* 128000 (log 128000)) 41812.6) 35.99997487578923 andgt; (/ (* 800000000 (log 800000000)) 41812.6) 392228.6064130373 392000 seconds ~ 4.5 days Any other procedures we’ve seen that are more work than simulating the Universe?:  Any other procedures we’ve seen that are more work than simulating the Universe? PS4: Break Lorenz Cipher Procedure:  PS4: Break Lorenz Cipher Procedure Try all possible wheel settings How many possible wheel settings: 5 choices for first wheel * 5 choices for second wheel * 5 choices for third wheel What is n? The number of wheels There are 5n possible wheel settings Lorenz Deciphering:  Lorenz Deciphering For PS4: you had 3 wheels, each with 5 possible settings: 53 = 125 combinations For WWII: Nazis has 12 wheels, each with more than 5 settings (up to 61 settings) 512 = 244 140 625 possible combinations Bletchley Park’s cryptographers had to solve a problem that is 1 953 125 times harder than PS4! (and had to figure out structure of Lorenz machine themselves) Motivation Helps…:  Motivation Helps… Confronted with the prospect of defeat, the Allied cryptanalysts had worked night and day to penetrate German ciphers. It would appear that fear was the main driving force, and that adversity is one of the foundations of successful codebreaking. Simon Singh, The Code Book Having bombs dropping on you is at least 1 million times more motivating than getting a gold star! Recap:  Recap So far, we have been talking amount the work a procedure requires In a few weeks, we will learn how to talk about the amount of work a problem requires That is, how much work is the best possible sorting procedure? For the general sorting problem, you can’t do better than quicksort: (n log2 n) But, VISA’s problem is simpler, so they can do much better: (n) The Endless Golden Age:  The Endless Golden Age Golden Age – period in which knowledge/quality of something doubles quickly At any point in history, half of what is known about astrophysics was discovered in the previous 15 years! Moore’s law today, but other advances previously: telescopes, photocopiers, clocks, etc. Endless Golden Age and “Grade Inflation”:  Endless Golden Age and 'Grade Inflation' Average student gets twice as smart and well-prepared every 15 years You had grade school teachers (maybe even parents) who went to college! If average GPA in 1970 is 2.00 what should it be today (if grading standards didn’t change)? Grade Inflation or Deflation?:  Grade Inflation or Deflation? 2.00 average GPA in 1970 ('gentleman’s C'?) * 2 better students 1970-1985 * 2 better students 1985-2003 * 3 admitting women, non-whites (1971) * 1.54 population increase * 0.58 increase in enrollment Average GPA today should be: 21.4 CS200 has only the best of the best students, and only the best 26/31 of them stayed in the course after PS1, so the average grade in CS200 should be 21.4*2*2*31/26 = 102.06 Students 1970 11,000 Students 2002 18,848 (12,595 UG) Short Golden Ages:  Short Golden Ages Golden Age – period in which knowledge/quality of something doubles quickly Endless golden age: at any point in history, the amount known is twice what was known 15 years ago Short golden age: knowledge doubles during a short, 'golden' period, but only improves gradually most of the time Slide18:  Average Goals per Game, FIFA World Cups Changed goalkeeper passback rule Goal-den age The Real Golden Rule?:  The Real Golden Rule? Why do fields like astrophysics, medicine, biology and computer science (?) have 'endless golden ages', but fields like music (1775-1825) rock n’ roll (1962-1973, or whatever was popular when you were 16) philosophy (400BC-350BC?) art (1875-1925?) soccer (1950-1974) baseball (1925-1950) movies (1920-1940) have short golden ages? Thanks to Leah Nylen for correcting this (previously I had only 1930-1940, but that is only true for Hollywood movies). The Story so Far…:  The Story so Far… The Liberal Arts:  The Liberal Arts Trivium (3 roads) language Quadrivium (4 roads) numbers Grammar Rhetoric Logic Arithmetic Geometry Music Astronomy From Lecture 1: Liberal Arts:  Liberal Arts Grammar: study of meaning in written expression Rhetoric: comprehension of verbal and written discourse Logic: argumentative discourse for discovering truth Arithmetic: understanding numbers Geometry: quantification of space Music: number in time Astronomy BNF replacement rules for describing languages, rules of evaluation for meaning Not yet… Interfaces between components (PS6-8), program and user (PS8) Rules of evaluation, if, recursive definitions Not much yet… wait until April Curves as procedures, fractals Yes, listen to 'Hey Jude!' Yes: Neil deGrasse Tyson says so Trivium Quadrivium From Lecture 1: Charge:  Charge If you want to do something important and be remembered, work in a field that has a short golden age from 2003-2018 Shakespeare will be known a thousand years from now, but no one will have heard of any 21st century playwright Bach will be known a thousand years from now, but no 20th century musician will be Pele will be known a thousand years from now, but no one will remember Beckham, Ronaldo or Zidane

Related presentations


Other presentations created by Funtoon

Marketing Mix 4ps
10. 10. 2007
0 views

Marketing Mix 4ps

manners 1
26. 06. 2007
0 views

manners 1

Telecom Seminar 5 20 06
18. 04. 2008
0 views

Telecom Seminar 5 20 06

nuti
10. 04. 2008
0 views

nuti

ch04
07. 04. 2008
0 views

ch04

Anthrax and Pan Flu scenario
30. 03. 2008
0 views

Anthrax and Pan Flu scenario

Software Development Survey
27. 03. 2008
0 views

Software Development Survey

tts
26. 03. 2008
0 views

tts

Tsamboulas
21. 03. 2008
0 views

Tsamboulas

eie1103
18. 03. 2008
0 views

eie1103

Fluid and Electrolyte
02. 01. 2008
0 views

Fluid and Electrolyte

lvmh
26. 06. 2007
0 views

lvmh

Sodium And Water Balance
04. 01. 2008
0 views

Sodium And Water Balance

dot nyc workshop
27. 09. 2007
0 views

dot nyc workshop

Christmas Greetings 02
02. 10. 2007
0 views

Christmas Greetings 02

people around you
03. 10. 2007
0 views

people around you

Impressionismus
12. 10. 2007
0 views

Impressionismus

Pres Feulefack Zeller
29. 11. 2007
0 views

Pres Feulefack Zeller

HydropowerProjects in Nepal
06. 12. 2007
0 views

HydropowerProjects in Nepal

Project Lead The Way
07. 12. 2007
0 views

Project Lead The Way

OHSummarize Sept2003
22. 08. 2007
0 views

OHSummarize Sept2003

SC tudor timeline
22. 08. 2007
0 views

SC tudor timeline

RDML Sharp MINWARA
07. 11. 2007
0 views

RDML Sharp MINWARA

discogenic lbp
17. 12. 2007
0 views

discogenic lbp

How can I miss you
24. 12. 2007
0 views

How can I miss you

hoeslywhyte
28. 12. 2007
0 views

hoeslywhyte

A I in the Military
29. 12. 2007
0 views

A I in the Military

Othello Slide Show
02. 11. 2007
0 views

Othello Slide Show

Day1Session10
07. 01. 2008
0 views

Day1Session10

StarryM 4
22. 08. 2007
0 views

StarryM 4

lhj Tudor Sailors
22. 08. 2007
0 views

lhj Tudor Sailors

elec ppt
21. 11. 2007
0 views

elec ppt

World Internet Project Media
23. 12. 2007
0 views

World Internet Project Media

martinez
26. 02. 2008
0 views

martinez

IndiaSinceIndepencen ce
28. 02. 2008
0 views

IndiaSinceIndepencen ce

march frames consumer
26. 06. 2007
0 views

march frames consumer

Manoj
26. 06. 2007
0 views

Manoj

MADHUSHALA
26. 06. 2007
0 views

MADHUSHALA

E Newsletter Aug2006
26. 06. 2007
0 views

E Newsletter Aug2006

Leipzig 02
26. 06. 2007
0 views

Leipzig 02

lecture2 CS598HL
26. 06. 2007
0 views

lecture2 CS598HL

lecture13
26. 06. 2007
0 views

lecture13

Lecture 10 Reliability
26. 06. 2007
0 views

Lecture 10 Reliability

13411
23. 11. 2007
0 views

13411

AFD 061206 049
22. 08. 2007
0 views

AFD 061206 049

Elizabeth Suti
03. 12. 2007
0 views

Elizabeth Suti

Mo0PC06 02 Sekar Sari
02. 01. 2008
0 views

Mo0PC06 02 Sekar Sari

corso Haccp
20. 11. 2007
0 views

corso Haccp

nw mn cropping system
04. 10. 2007
0 views

nw mn cropping system

RLEP 2 Overview Bart Graham
13. 11. 2007
0 views

RLEP 2 Overview Bart Graham

himinhvelfingin
14. 11. 2007
0 views

himinhvelfingin

Real time2
22. 08. 2007
0 views

Real time2

le amiche di sergio
26. 06. 2007
0 views

le amiche di sergio

tudor monarchs
22. 08. 2007
0 views

tudor monarchs

daphne OMAN feb04
22. 08. 2007
0 views

daphne OMAN feb04

PickMaster 2 10 Ext Feb 25
07. 01. 2008
0 views

PickMaster 2 10 Ext Feb 25