Title: CS 60 Slides
1ACM reminders
October 30 -- HMC Mock contest
Good times ?
November 10 -- ACM contest
current list of competitors
Accepted Harvey Mudd College HMC 1
Accepted Harvey Mudd College HMC 2
Accepted Harvey Mudd College HMC 3
Pending Mount San Antonio College
MtSAC_at_Voidiesqf Pending Mount San Antonio
College MtSAC_at_Floatiesqi Pending Riverside
Community College Platinum Pending Riverside
Community College The Code Machine
Pending Riverside Community College CodeBlue
Pending University of California, San Diego
UCSD Rock Pending University of California, San
Diego UCSD Paper Pending University of
California, San Diego UCSD Scissors
Pending University of Southern California
Trojan Horse Pending University of Southern
California Trojan Pride Pending University of
Southern California Trojans
Pending Azusa Pacific University 4Alpha2Omega
Pending Brigham Young University -- Hawaii
Campus C-Siders 1 Pending Brigham Young
University -- Hawaii Campus C-Siders 2
Pending California Lutheran University Java the
Hut Pending California Lutheran University Just
Wanna Program Pending California Lutheran
University javac this.java Pending California
State University Long Beach Beach1
Pending California State University Long Beach
Beach2 Pending California State University Long
Beach Beach3 Pending California State
University, Northridge CSUN Red
Pending California State University, Northridge
CSUN Black Pending California State University,
Northridge CSUN-3 Pending El Camino College
ECC Beta
November 13 -- Final acm class contest wrap-up
2C Map
www.dinkumware.com/htm_cpl/index.html
www.sgi.com/tech/stl/
map
multimap
include ltmapgt
include ltmapgt
set of key/value pairs
3C Map
www.dinkumware.com/htm_cpl/index.html
www.sgi.com/tech/stl/
map
multimap
include ltmapgt
include ltmapgt
set of key/value pairs
(implemented as a balanced binary tree)
4C Map
www.dinkumware.com/htm_cpl/index.html
www.sgi.com/tech/stl/
map
multimap
include ltmapgt
include ltmapgt
set of key/value pairs
Fast searching by key Slow searching by value
(implemented as a balanced binary tree)
5C Map
define MP make_pair typedef pairltint,intgt
PII mapltPII,intgt m mMP(0,1) 10 mMP(0,2)
17 mMP(1,2) 5 mMP(2,0) 12 //
probably not worth it for graphs... mapltstring,int
gt m // definitely worth it
here mArcOS 110 // as an
associative array mTheoComp
140 multimapltstring,stringgt d // as a
dictionary d.insert(MP(fun,c coding)) //
methods exist to get d.insert(MP(fun,ACM
coding)) // all of funs entries
10
0
1
17
5
12
2
6Geometric Problems
Problem 1 - Binary Space Partitions
Basic idea draw objects from far (first) to near
(last).
observer
7Geometric Problems
Problem 1 - Binary Space Partitions
z
(50,240)
(20,240)
C
(-30,230)
(-60,230)
(100,220)
(70,220)
B
(50,220)
(20,220)
D
(-30,210)
(-60,210)
(100,200)
(70,200)
(-20,80)
(-50,80)
A
(70,70)
(40,70)
E
(-20,60)
(-50,60)
(70,50)
(40,50)
x
Basic idea draw objects from far (first) to near
(last).
(0,-big)
observer
8Geometric Problems
Problem 1 - Binary Space Partitions
Input
5 4 -50 60 -20 60 -20 80 -50 80 4 -60 210 -30 210
-30 230 -60 230 4 20 220 50 220 50 240 20 240 4
70 200 100 200 100 220 70 220 4 40 50 70 50 70 70
40 70
first part
9Geometric Problems
Problem 1 - Binary Space Partitions
z
(50,240)
(20,240)
C
(-30,230)
(-60,230)
(100,220)
(70,220)
B
(50,220)
(20,220)
D
(-30,210)
(-60,210)
(100,200)
(70,200)
(0,140)
(-20,80)
(-50,80)
A
(70,70)
(40,70)
E
(-20,60)
(-50,60)
(70,50)
(40,50)
(-15,0)
x
Basic idea draw objects from far (first) to near
(last).
(0,-big)
observer
10Geometric Problems
Problem 1 - Binary Space Partitions
z
C
B
D
(0,140)
A
E
AB
CDE
(-15,0)
x
Basic idea draw objects from far (first -- LEFT)
to near (last -- RIGHT).
(0,-big)
observer
11Geometric Problems
Problem 1 - Binary Space Partitions
z
C
B
D
(-70,150)
(70,150)
(0,140)
A
E
AB
CDE
A
B
CD
E
(-15,0)
x
Basic idea draw objects from far (first -- LEFT)
to near (last -- RIGHT).
(0,-big)
observer
12Geometric Problems
Problem 1 - Binary Space Partitions
Input
5 4 -50 60 -20 60 -20 80 -50 80 4 -60 210 -30 210
-30 230 -60 230 4 20 220 50 220 50 240 20 240 4
70 200 100 200 100 220 70 220 4 40 50 70 50 70 70
40 70 2 0 140 -15 0 70 150 -70 150
first part
second part
13Geometric Problems
Problem 1 - Binary Space Partitions
Input
5 4 -50 60 -20 60 -20 80 -50 80 4 -60 210 -30 210
-30 230 -60 230 4 20 220 50 220 50 240 20 240 4
70 200 100 200 100 220 70 220 4 40 50 70 50 70 70
40 70 2 0 140 -15 0 70 150 -70 150
first part
second part
the objects, in the order they would be rendered
by this BSP
Output
ECDAB
14Geometric Problems
Problem 2 - Visualizing cubes
3 3 1 3 1 2
15Geometric Problems
Problem 2 - Visualizing cubes
3 3 1 3 1 2
left wall
right wall
floor
left wall
floor
Suppose you rotate so that
floor
right wall
right wall
left wall
What is the resulting stacking pattern?
16Geometric Problems
Problem 2 - Visualizing cubes
3 3 1 3 1 2
left wall
right wall
floor
left wall
floor
Suppose you rotate so that
floor
right wall
3 2 1 2 1 1 2 1
right wall
left wall
What is the resulting stacking pattern?
17Geometric Problems
Problem 2 - Visualizing cubes
?!?
18All-pairs shortest paths
Floyd-Warshall algorithm
B
8
9
to
A
D
E
A
B
C
13
C
A
6
B
0
C
from
7
1
12
D
D
E
E
11
19All-pairs shortest paths
Floyd-Warshall algorithm
B
8
9
to
A
D
E
A
B
C
13
C
A
6
B
0
C
from
7
1
12
D
D
E
E
11
0
D0 (dij )
0
dij shortest distance from i to j through no
nodes
k
dij shortest distance from i to j through
nodes 1, , k
20All-pairs shortest paths
Floyd-Warshall algorithm
B
8
9
to
A
D
E
A
B
C
13
C
A
6
B
0
C
from
7
1
12
D
D
E
E
11
0
D0 (dij )
1
dij shortest distance from i to j through
nodes 1
k
dij
21All-pairs shortest paths...
Floyd-Warshall algorithm
A
B
k
dij
C
D
E
0
D0 (dij )
A
0
8
13
-
1
A
B
-
0
-
6
12
B
C
-
9
0
-
-
C
D
7
15
0
0
8
D
E
-
-
-
11
0
E
1
D1 (dij )
k
dij shortest distance from i to j through
nodes 1, , k
22All-pairs shortest paths...
Floyd-Warshall algorithm
A
B
k
dij
C
D
E
0
D0 (dij )
A
0
8
13
-
1
A
B
-
0
-
6
12
B
C
-
9
0
-
-
C
D
7
15
0
0
8
D
E
-
-
-
11
0
E
1
D1 (dij )
k
dij shortest distance from i to j through
1, , k
23All-pairs shortest paths...
Floyd-Warshall algorithm
A
B
k
dij
C
D
E
0
D0 (dij )
A
0
8
13
-
1
A
B
-
0
-
6
12
B
C
-
9
0
-
-
C
D
7
15
0
0
8
D
E
-
-
-
11
0
E
1
D1 (dij )
k
dij shortest distance from i to j through
1, , k
24All-pairs shortest paths...
0
8
13
14
1
A
0
8
13
14
1
A
13
0
6
6
12
B
-
0
-
6
12
B
22
9
0
15
21
C
-
9
0
15
21
C
7
9
0
0
8
D
7
15
0
0
8
D
18
20
11
11
0
E
-
-
-
11
0
E
4
D4 (dij )
2
D2 (dij )
A
0
8
13
14
1
A
0
8
12
12
1
B
-
0
-
6
12
B
13
0
6
6
12
C
-
9
0
15
21
C
22
9
0
15
21
D
7
9
0
0
8
D
7
9
0
0
8
E
-
-
-
11
0
E
18
20
11
11
0
5
3
D5 (dij )
D3 (dij )
to store the path, another matrix can track the
last intermediate vertex