CS 60 Slides - PowerPoint PPT Presentation

About This Presentation
Title:

CS 60 Slides

Description:

On the 405, in traffic, being chased by police (and TV) helicopters. ... Denver, CO or Minneapolis, MN. DC for the inauguration. What is this course about? ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 44
Provided by: Kel7163
Learn more at: https://www.cs.hmc.edu
Category:

less

Transcript and Presenter's Notes

Title: CS 60 Slides


1
Driving N on the Dalton Highway (though it feels
like it!)
Welcome to Programming Practicum
Victorville, for DARPA's UGC
Pittsburgh
Putting the C into CS
University of St. Petersburg
Waiting for the snow enveloping you on Route 5 N
to melt
DC for the inauguration
exploring martian soil
Denver, CO or Minneapolis, MN
On the 405, in traffic, being chased by police
(and TV) helicopters.
You arent here
Worldcom Headquarters
Engineering dept.
Krispy Kremes drive-through
writing clinic reports
Waiting in line to vote in the Florida primaries
rebooting knuth (or turing or)
coding chunky strings
Being dragged off-course 18 miles into a marathon
race by a crazed spectator
clinic liaison phone call
installing Debian 3.1
Teaching Honors English for Janice Barbee at
Pomona High School
Leading a Gray Davis / Gary Coleman / Arnold
T-800 Schwarzenegger gubernatorial fundraiser
Massey University Palmerston North, NZ
Mailing something at the Claremont Post Office
the dumpster
2
What is this course about?
3
What is this course about?
  • A chance to improve your programming skills

Algorithm analysis and insight
optimizing coding time
What
Program design and implementation
ACM programming contest
Hands-on practice with algorithms and techniques
Why
Familiarity with Javas libraries OR your choice
of language
Research/prototype programming
"somewhat reasonable"
Unofficial course name CS -70
4
Last year's ACM regional programming contest
Aaron Pribadi, Stuart Persteiner, and Daniel
Lubarov
Anak Yodpinyanee Jason GarretGlaser
Kevin Oelze, Andrew Hunter, and Kwang Ketcham
Marquis Wang, Josh Ehrlich, and Daniel Fielder
5
Class Organization
alternating format
discussion sessions
lab sessions
  • teams may use 1 machine per person (only the
    mock contest adheres to ACM rules)
  • these problems count for each member of the group
  • problem and program analysis
  • discussion of strategy and coding tips
  • deciding on functional decomposition, data
    structures, language facilities, and algorithms
    to use in teams of 2-3

a team can always practice with only 1 machine
  • sometimes new problems, other times with known
    ones
  • 4 problems given out per week

6
Class Organization
Feedback from prior semesters
  • there should be an opportunity to start coding
    cold
  • make individual vs. team-based work clear,
    lectures vs. labs
  • problems are always individually submitted -- but
  • each team member may submit shared lab problems
  • provide the code to all team members
  • you may or may not choose to work as a team
    afterwards
  • submit for each person (email me if there are
    problems)
  • problems per person per week?
  • about 12 (if you work on a team in lab)
  • and consider all of the weeks of the term!
  • snacks and jotto!

7
Course Organization
Jan 20 Welcome! Review of dynamic
programming 5 problems Jan 27 Lab/Mock
contest session 4 problems Feb 3 Discussion
session on geometry problems 4 problems Feb 10
Lab/Mock contest session 4 problems Feb 17
Discussion session on graph problems 4
problems Feb 24 Lab/Mock contest session 4
problems Mar 3 No class (I'll be out of
town Chattanooga!) Mar 10 Discussion
session on misc. algorithms Mar 17 Spring
break Mar 24 Mock ACM contest, 9pm 1200am,
5 problems Mar 31 Discussion and wrap-up for
the semester
You may submit problems until the end of exams
CONTEST in San Diego ???
8
Course webpage
references
problem statements and sample data
problems you have solved
administrative info
9
Grading
CS 189 is graded individually... (its possible
to take it P/F, too)
though not for CS elective credit
Coding Guidelines
  • problems can be done any time during the
    semester
  • discussion of algorithms always OK
  • coding should be within teams
  • you may use external references (but not
    solutions!)
  • one person should take the lead on each problem
  • use /cs/ACM/acmSubmit ltfilegt to submit
  • try things out !

the reason for ACM!
10
Problem credits
Problems are worth double if
  • You solve them during the 415 - 530 lab
    sessions
  • It's one of the "extra difficult" problems,
    which may be determined as we go
  • Any standard language is OK -- but do keep in
    mind that the competition allows only Java, C,
    and C .

the team gets credit, up to 3 people
Problems are worth triple if they are written up
for "the book"
Language Choice?
Other "standard" languages
C, Python, Ruby
somewhat reasonable alternatives will also be
considered
11
The "book"
Overheard at last fall's contest
We will begin a multi-term effort to create an
HMC "book"
Problems contributed to the book are worth
triple, but
- need a thorough introductory explanation
a secret weapon?
- need to be in Java or C
- need to be beautifully formatted
- need to be fully commented
- need to be useful for people who did not write
it!
- variable names and other constructs evident
Sign up for a problem if you want to do this.
(It's OK to work in a team of 2 or 3, as well.)
12
Spring 2008 summary languages
17 (2)
8
4
16 (2)
1 (1)
6 (1)
20 (12) (2)
3 (1)
1
1
2
11 (1)
1 (1)
17 (9) (2)
4 (2)
1
2
2
8
3
2
8 (2)
13 (10)
14 (9)
1
21 (16) (4)
1
1
15 (14)
number of 2x scores
number of 4x scores
python 82 java 60 C 40
d 8 ruby 6 scheme 3
lua 2 awk 2 js 2
sql cobol basic x86 asm pascal mathematica sh,
latex
Tallies per problem and per language (thus far)
1 each
13
ACM Jotto finale Fall '08
Frosh
Sophs
Jrs
Srs
Others
pluto 0
pluto 2
pluto 3
pluto 1
pluto 1
andes 1
andes 1
andes 0
andes 2
andes 1
wired 1
wired 1
wired 1
wired 1
wired 0
xenon 1
xenon 1
xenon 1
xenon 1
xenon 0
tenet 1
tenet 0
tenet 0
tenet 3
tenet 0
clack 2
clack 1
clack 1
clack 0
clack 1
grime 1
grime 1
grime 1
grime 1
grime 0
these 0
these 1
these 0
these 4
these 1
flour 0
flour 2
flour 2
flour 1
flour 1
This has already set the record for the longest
jotto game I've played at Mudd!
14
Dynamic programming!
15
Excitement from the judges room
16
Excitement from the judges room
17
Backpacks not permitted
18
Dynamic programming
When a seemingly intractable problem has lots of
repeated substructure, go DP!
Build a table of partial results.
Replace computation with table look-up when
possible
For example
19
Dynamic programming
When a seemingly intractable problem has lots of
repeated substructure, go DP!
Build a table of partial results.
Replace computation with table look-up when
possible
the binary-decimal problem, for example
Output
2 6 3 19 0
Input
Numbers, N, up to 106
10 1110 111 11001
the smallest decimal multiple of N with only the
digits 0 and 1 !
0 marks the end of the input
Ideas?
20
One way
Count up to the solution, starting from 1
insight from CS 60!
adding digits changes the error (remainder) in
predictable ways
21
Dynamic programming
Storing intermediate results in a table for fast
look-up
input N 6
possible remainders upon dividing by N (6)
0
1
2
3
4
5




1
2
of digits in answer
3
4
22
Dynamic programming
Storing intermediate results in a table for fast
look-up
input N 6
possible remainders upon dividing by N (6)
0
1
2
3
4
5




1
1
2
of digits in answer
3
4
23
Dynamic programming
Storing intermediate results in a table for fast
look-up
input N 6
possible remainders upon dividing by N (6)
0
1
2
3
4
5




1
1
1
2
10
11
of digits in answer
3
4
24
Dynamic programming
Storing intermediate results in a table for fast
look-up
input N 6
possible remainders upon dividing by N (6)
0
1
2
3
4
5




1
1
1
2
10
11
of digits in answer
1
3
10
11
111
110
4
25
Dynamic programming
Storing intermediate results in a table for fast
look-up
input N 6
possible remainders upon dividing by N (6)
0
1
2
3
4
5




1
1
1
2
10
11
of digits in answer
1
3
10
11
111
110
1
1110
111
110
10
11
4
26
DP!
Only checking values for which a remainder has
not yet been used
Fast
27
Problem Set 0
(5 problems)
Our ACM problems' mascot
28
Problem Set 0
(4 problems)
In teams of 23, read over these first three
problems
  • Where does the structure of the problem depend
    on similar (but smaller!) substructure? Or not?
  • How might you build up a table of values toward
    an overall solution?
  • Think of your next 5-letter jotto word !

29
Another example
binary-as-decimal problem
The "haysale" problem
Input
Capacity of our farmer's hay bin
24 6 21 16 10 9 5 1
Number of bales of hay
maximum possible sum lt capacity
Idea?
24
try all possible subsets?
Size of each bale of hay
Output
naïve running time?
30
Dynamic programming
Idea keep a table of all possible capacities
for bales 1..k
Input
Capacity
24 6 21 16 10 9 5 1
bale 6
bale 5
size of each bale
bale 4
bale 3
bale 2
bale 1
31
Jotto guesses 1 and 2
A word-guessing game similar to mastermind
Sophs
Jrs
Srs
Grads
Frosh
?????
?????
?????
?????
?????
32
See you next Tuesday
bring a laptop, if you have one
33
The ACM regionals seemed to be channeling CS 60 ?!
34
Dinner
35
This weekend's ACM regional programming contest
Aaron Pribadi, Stuart Persteiner, and Daniel
Lubarov
Anak Yodpinyanee Jason GarretGlaser
Kevin Oelze, Andrew Hunter, and Kwang Ketcham
Marquis Wang, Josh Ehrlich, and Daniel Fielder
36
This weekend's ACM regional programming contest
Aaron Pribadi, Stuart Persteiner, and Daniel
Lubarov
Anak Yodpinyanee Jason GarretGlaser
Kevin Oelze, Andrew Hunter, and Kwang Ketcham
Marquis Wang, Josh Ehrlich, and Daniel Fielder
37
HMC details
Aaron Pribadi, Stuart Persteiner, and Daniel
Lubarov
www.socalcontest.org
Anak Yodpinyanee Jason GarretGlaser
Kevin Oelze, Andrew Hunter, and Kwang Ketcham
Marquis Wang, Josh Ehrlich, and Daniel Fielder
38
Scanner sc new Scanner(System.in)
even a bit easier!
This sure is sum code
to the max
Martijn is VERY shifty!
Where is the table?
Martijn is shifty!
Thanks, Martijn!
39
Pebbles
consider all possibilities for pebbling each row
- they only depend on the previous row's best
scores!
DP Idea
Subset chosen (pebbles)
Input
000
001
010
011
100
101
110
111
0
3 8 6 7 9 1 4 6 1
1
Row
2
Store the BEST score available for each possible
subset.
a
b
c
Square array, up to 15x15, of integers from 1 to
99
40
Pebbles
consider all possibilities for pebbling each row
- they only depend on the previous row's best
scores!
DP Idea
Subset chosen (pebbles)
Input
000
001
010
011
100
101
110
111
0
6
8
x
3
9
x
x
0
3 8 6 7 9 1 4 6 1
1
Row
2
Store the BEST score available for each possible
subset.
a
b
c
Square array, up to 15x15, of integers from 1 to
99
41
Pebbles
consider all possibilities for pebbling each row
- they only depend on the previous row's best
scores!
DP Idea
Subset chosen (pebbles)
Input
000
001
010
011
100
101
110
111
0
6
8
x
3
9
x
x
0
3 8 6 7 9 1 4 6 1
09
13
90
76
80
1
x
x
x
9
4
9
13
8
Row
2
a
b
c
Store the BEST score available for each possible
subset.
Square array, up to 15x15, of integers from 1 to
99
42
Pebbles
consider all possibilities for pebbling each row
- they only depend on the previous row's best
scores!
DP Idea
Subset chosen (pebbles)
Input
000
001
010
011
100
101
110
111
0
6
8
x
3
9
x
x
0
3 8 6 7 9 1 4 6 1
09
13
90
76
80
1
x
x
x
9
4
9
13
8
Row
x
x
x
2
c13
b9
a9
013
?
a
b
c
Store the BEST score available for each possible
subset.
What is the best here?
Square array, up to 15x15, of integers from 1 to
99
running time?
43
Pebbles
binary-as-decimal problem
"pebbles" problem (2007 ACM regionals)
Input
71 24 95 56 54 85 50 74 94 28 92 96 23 71 10 23
61 31 30 46 64 33 32 95 89
Idea
71 24 95 56 54 85 50 74 94 28 92 96 23 71 10 23
61 31 30 46 64 33 32 95 89
maximum possible sum
572
Square array, up to 15x15, of integers from 1 to
99
Output
place "pebbles" on integers, trying to maximize
total, but no two pebbles may be adjacent
code
Write a Comment
User Comments (0)
About PowerShow.com