240 likes | 417 Views
ACM 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@Voidies$qf
E N D
ACM 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@Voidies$qf Pending Mount San Antonio College: MtSAC@Floaties$qi 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
C++ Map www.dinkumware.com/htm_cpl/index.html www.sgi.com/tech/stl/ map multimap #include <map> #include <map> set of key/value pairs
C++ Map www.dinkumware.com/htm_cpl/index.html www.sgi.com/tech/stl/ map multimap #include <map> #include <map> set of key/value pairs (implemented as a balanced binary tree)
C++ Map www.dinkumware.com/htm_cpl/index.html www.sgi.com/tech/stl/ map multimap #include <map> #include <map> set of key/value pairs Fast: searching by key Slow: searching by value (implemented as a balanced binary tree)
C++ Map #define MP make_pair typedef pair<int,int> PII; map<PII,int> m; m[MP(0,1)] = 10; m[MP(0,2)] = 17; m[MP(1,2)] = 5; m[MP(2,0)] = 12; // probably not worth it for graphs... map<string,int> m; // definitely worth it here m[“ArcOS”] = 110; // as an associative array m[“TheoComp”] = 140; multimap<string,string> d; // as a dictionary d.insert(MP(“fun”,“c++ coding”)); // methods exist to get d.insert(MP(“fun”,“ACM coding”)); // all of “fun”s entries 10 0 1 17 5 12 2
Geometric Problems Problem 1 - Binary Space Partitions Basic idea: draw objects from far (first) to near (last). observer
Geometric 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
Geometric 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
Geometric 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
Geometric Problems Problem 1 - Binary Space Partitions z C B D (0,140) A E CDE AB (-15,0) x Basic idea: draw objects from far (first -- LEFT) to near (last -- RIGHT). (0,-big) observer
Geometric Problems Problem 1 - Binary Space Partitions z C B D (-70,150) (70,150) (0,140) A E CDE AB E CD A B (-15,0) x Basic idea: draw objects from far (first -- LEFT) to near (last -- RIGHT). (0,-big) observer
Geometric 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
Geometric 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
Geometric Problems Problem 2 - Visualizing cubes 3 3 1 3 1 2
Geometric 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?
Geometric 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?
Geometric Problems Problem 2 - Visualizing cubes ?!?
0 8 13 - 1 - 0 - 6 12 - 9 0 - - 7 - 0 0 - - - - 11 0 All-pairs shortest paths “Floyd-Warshall algorithm” B 8 9 to A D E B C A 13 C A 6 B 0 from C 7 1 12 D D E E 11
0 8 13 - 1 - 0 - 6 12 - 9 0 - - 7 - 0 0 - - - - 11 0 All-pairs shortest paths “Floyd-Warshall algorithm” B 8 9 to A D E B C A 13 C A 6 B 0 from C 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}
0 8 13 - 1 - 0 - 6 12 - 9 0 - - 7 - 0 0 - - - - 11 0 All-pairs shortest paths “Floyd-Warshall algorithm” B 8 9 to A D E B C A 13 C A 6 B 0 from C 7 1 12 D D E E 11 0 D0 = (dij ) 1 dij = shortest distance from i to j through nodes {1} k dij =
0 0 8 8 13 13 - - 1 1 - - 0 0 - - 6 6 12 12 - - 9 9 0 0 - - - - 7 7 - - 0 0 0 0 - - - - - - - - 11 11 0 0 All-pairs shortest paths... “Floyd-Warshall algorithm” A k B dij = C D E 0 D0 = (dij ) A A 0 8 13 - 1 B B - 0 - 6 12 C C - 9 0 - - D D 7 15 0 0 8 E E - - - 11 0 1 D1 = (dij ) k dij = shortest distance from i to j through nodes {1, …, k}
0 0 8 8 13 13 - - 1 1 - - 0 0 - - 6 6 12 12 - - 9 9 0 0 - - - - 7 7 - - 0 0 0 0 - - - - - - - - 11 11 0 0 All-pairs shortest paths... “Floyd-Warshall algorithm” A k B dij = C D E 0 D0 = (dij ) A A 0 8 13 - 1 B B - 0 - 6 12 C C - 9 0 - - D D 7 15 0 0 8 E E - - - 11 0 1 D1 = (dij ) k dij = shortest distance from i to j through {1, …, k}
0 0 8 8 13 13 - - 1 1 - - 0 0 - - 6 6 12 12 - - 9 9 0 0 - - - - 7 7 - - 0 0 0 0 - - - - - - - - 11 11 0 0 All-pairs shortest paths... “Floyd-Warshall algorithm” A k B dij = C D E 0 D0 = (dij ) A A 0 8 13 - 1 B B - 0 - 6 12 C C - 9 0 - - D D 7 15 0 0 8 E E - - - 11 0 1 D1 = (dij ) k dij = shortest distance from i to j through {1, …, k}
All-pairs shortest paths... A 0 8 13 14 1 A 0 8 13 14 1 B 13 0 6 6 12 B - 0 - 6 12 C 22 9 0 15 21 C - 9 0 15 21 D 7 9 0 0 8 D 7 15 0 0 8 E 18 20 11 11 0 E - - - 11 0 4 D4 = (dij ) 2 D2 = (dij ) A 0 8 12 12 1 A 0 8 13 14 1 B 13 0 6 6 12 B - 0 - 6 12 C 22 9 0 15 21 C - 9 0 15 21 D 7 9 0 0 8 D 7 9 0 0 8 E 18 20 11 11 0 E - - - 11 0 5 3 D5 = (dij ) D3 = (dij ) to store the path, another matrix can track the last intermediate vertex