Download presentation
Presentation is loading. Please wait.
Published byRandolph Wade Modified over 9 years ago
1
Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports Lecture clinic liaison phone call coding chunky strings rebooting turing reading requests Engineering dept. the dumpster University of St. Petersburg On the 405, in traffic, being chased by police (and TV) helicopters. Mailing something at the Claremont Post Office Waiting for the snow enveloping you on Route 5 N to melt
2
What is this course about? A chance to “improve” your C/C++ …
3
What is this course about? A chance to “improve” your C/C++ … Unofficial course name: CS -70
4
What is this course about? A chance to “improve” your C/C++ … Unofficial course name: CS -70 Code commenting Using globals Building classes STL Memory Leaks
5
What is this course about? A chance to “improve” your C/C++ … Unofficial course name: CS -70 Code commenting Using globals Building classes STL Memory Leaks CS 70
6
What is this course about? A chance to “improve” your C/C++ … Preparation for the ACM competition... Problem Insight and Execution... Unofficial course name: CS -70 Code commenting Using globals Building classes STL Memory Leaks CS 70
7
2000 ACM Teams
8
Organization Solving problems in teams 3 team members, more or less 2 problems/week, more or less submission through /cs/ACM/acmSubmit class web page at www.cs.hmc.edu/ACM a must!
9
Grading P/F by default -- but it can be graded Coding Guidelines 1.75 problems/week => A 1.25 problems/week => B 0.75 problems/week => C 0.25 problems/week => D share coding tasks within teams, not among them discussion of algorithms always OK start from scratch each time!
10
Course Outline Sep 11 continental fare Sep 18 slim jims Sep 25 Pepperedge Farm Oct 2 Krispy Kreme Oct 9 Drake’s coffee cake Oct 16 baklava Oct 23 (fall break) Oct 30 HMC Contest - 9:00 pm to 1:00 am ? Nov 6 popcorn Nov 10 (Sat) -- ACM Contest at Riverside Com. Col. Nov 13 Wrap-up and problem discussion
11
ACM topics Standard Library (STL) Algorithms/data structures Coding/Contest strategies ContestCSTopic Overlearning the above
12
ACM topics Standard Library (STL) Algorithms/data structures Coding/Contest strategies ContestCSTopic Overlearning the above
13
ACM topics Standard Library (STL) Algorithms/data structures Coding/Contest strategies ContestCSTopic Overlearning the above
14
ACM topics Standard Library (STL) Algorithms/data structures Coding/Contest strategies ContestCSTopic Overlearning the above
15
Problems Intergalactic IRC strings Input: The “echo” problem. (echo.cc) stdin The “unscramble” problem. (unscramble.cc) The “digital root” problem. (digroot.cc) starting... sorting... hehelllloo spamanyspamone howstheweather
16
Problems Intergalactic IRC strings Input: Status Report Output: The “echo” problem. (echo.cc) stdin stdout The “unscramble” problem. (unscramble.cc) The “digital root” problem. (digroot.cc) starting... sorting... An echo string with buffer size ten Not an echo string, but still consistent Not consistent with the theory hehelllloo spamanyspamone howstheweather
17
Resources... Online STL refs http://www.dinkumware.com/htm_cpl/index.html http://www.sgi.com/tech/stl/ http://www.josuttis.com/libbook/ Useful stuff for this week’s problems Both good overall references Example code string string t, s = “Hawaii 2002”; getline(cin,t); // suppose t is “Harvey Mudd” if (t > s) … // comparison (==, !=, …) t += ‘ ’ + ‘i’ + “n ” + s; // concatenation s = t.substr(7,4); // s is “Mudd” s[1]; // s[1] is ‘u’ s.length(); // returns 4 t.find(‘a’); // returns 1 (where ‘a’ is) t.find(‘a’,2); // returns 16 (starts at 2) // find returns a value of type string::size_type // if what is sought isn’t there, find returns string::npos #include
18
Resources... pair typedef pair PS; PS mypair = make_pair(“hello”,“world”); mypair.first; // these are public members mypair.second; struct MYLESS : public less { bool operator()(PS x,PS y) { return x.second < y.second; // etc. } }; MYLESS mybad; PS* psArray = new PS[1000]; // array of PS // putting mybad to work... sort( psArray, psArray+n ); // default sort sort( psArray, psArray+n, mybad ); #include sort #include function objects #include “less”
20
Resources... pair typedef pair PSS; PSS mypair = make_pair(“hello”,“world”); mypair.first; // these are public members mypair.second; vector v; // typedefs ~ good v.reserve(10); // assure 10 spots v.push_back(mypair); // mypair -> last item v.back(); // returns mypair v.pop_back(); // removes last element v.size(); // # of elements v[i]; // ith element sort( v.begin(), v.end() ); // default sort sort( v.begin(), v.end(), mycompare ); #include sort #include vector #include
21
Intro STL Data Structure The number of configurations the # of cups to follow the # of peas in each cup # of cups # of peas... Input: 2 5 1 3 0 3 0 3 7 0 7 The # of transitions from a root configuration to the given one. Output: 3232 The “split pea” problem (also see the webpage) stdin stdout input output shaken or stirred?
22
Intro Problem The “NAND” problem (also see the webpage) file to create: nand.cc Problem NAND gates can specify any logical function. Consider two N-bit binary numbers, A and B. There is a logical function mapping A and B to the overflow bit of their sum. A = 10 B = 11 A+B = 101 NAND x y x|y 0 0 1 0 1 1 1 0 1 1 1 0 the overflow bit -- it’s a function of the input bits
23
Intro Problem The “NAND” problem (also see the webpage) file to create: nand.cc Problem: NAND gates can specify any logical function. Consider two N-bit binary numbers, A and B. There is a logical function mapping A and B to the overflow bit of their sum. Lines with two integers > 0.Input: 1 10 10 20 Same lines, plus the max # of steps to get to 1 in the given range. Output: 1 10 20 10 20 21
24
Topics Outline Sep 5 Basic coding strategies (ACM style) Sep 12 Dynamic programming ’n’ data structures Sep 19 Search algorithms ’n’ data structures Sep 26 Numerical algorithms: DEs, equations Oct 3 I/O in C/C++ = building parsers quickly Oct 10 Built-in string functions: strcmp, strtok, and the like Oct 24 Built-in math functions: atan vs. atan2, precision issues,... Oct 31 Geometric algorithms ‘n’ data structures Nov 7 Contest strategies, logistics, preparing materials
25
A chance to “improve” your C/C++ … Preparation for the ACM competition... Problem Insight and Execution... Get into the minds of the judges Anxiety! 1 2 prog practice What is this course about?
26
Get into the minds of the judges Key Skill #1: mindreading
27
Key Skill #2: anxiety Anxiety!
28
What, no contest!? We will have a mock contest at the end of the term. tentatively Tuesday, April 17 four hours (from 4:15 to 8:15) contest conditions will apply dinner will be provided... - only written material can be used - only one machine per team - (we will have a chair for each team member) - minimal feeback from submissions - time penalties for incorrect submssions This will be the final class session except we’ll stretch team size to 1-4 people...
29
Data Structures Sep 11 make_pair string Sep 18 map, multimap, set, multiset Sep 25 vector, deque, list Oct 2 bitset, stack,... Oct 9 algorithms I Oct 16 algorithms II Oct 23 (fall break) Oct 30 HMC Contest - 9:00 pm to 1:00 am ? Nov 6 I/O tips Nov 10 (Sat) -- ACM Contest at Riverside Com. Col. Nov 13 Wrap-up and problem discussion
30
printed version after this one
31
Welcome to Programming Practicum “Putting the C into CS” You aren’t here writing clinic reports Lecture clinic liaison phone call coding chunky strings rebooting turing reading requests Engineering dept. the dumpster University of St. Petersburg On the 405, in traffic, being chased by police (and TV) helicopters. Mailing something at the Claremont Post Office Waiting for the snow enveloping you on Route 5 N to melt
32
What is this course about? A chance to “improve” your C/C++ … Preparation for the ACM competition... Problem Insight and Execution... Solving problems in teams 3 team members, more or less 2 problems/week, more or less submission through /cs/ACM/acmSubmit class web page at www.cs.hmc.edu/ACM
33
Grading P/F by default -- but it can be graded Coding Guidelines 1.75 problems/week => A 1.25 problems/week => B 0.75 problems/week => C 0.25 problems/week => D share coding tasks within teams, not among them discussion of algorithms always OK start from scratch each time!
34
ACM topics Standard Library (STL) Algorithms/data structures Coding/Contest strategies ContestCSTopic Overlearning the above
35
“Problems” Intergalactic IRC strings Input: The “echo” problem. (echo.cc) stdin The “unscramble” problem. (unscramble.cc) The “digital root” problem. (digroot.cc) starting... sorting... hehelllloo spamanyspamone howstheweather
36
“Problems” Intergalactic IRC strings Input: Status Report Output: The “echo” problem. (echo.cc) stdin stdout The “unscramble” problem. (unscramble.cc) The “digital root” problem. (digroot.cc) starting... sorting... An echo string with buffer size ten Not an echo string, but still consistent Not consistent with the theory hehelllloo spamanyspamone howstheweather
37
Resources... Online STL refs http://www.dinkumware.com/htm_cpl/index.html http://www.sgi.com/tech/stl/ http://www.josuttis.com/libbook/ Useful stuff for this week’s problems Both good overall references Example code string string t, s = “Hawaii 2002”; getline(cin,t); // suppose t is “Harvey Mudd” if (t > s) … // comparison (==, !=, …) t += ‘ ’ + ‘i’ + “n ” + s; // concatenation s = t.substr(7,4); // s is “Mudd” s[1]; // s[1] is ‘u’ s.length(); // returns 4 t.find(‘a’); // returns 1 (where ‘a’ is) t.find(‘a’,2); // returns 16 (starts at 2) // find returns a value of type string::size_type // if what is sought isn’t there, find returns string::npos #include
38
Resources... pair typedef pair PS; PS mypair = make_pair(“hello”,“world”); mypair.first; // these are public members mypair.second; struct MYLESS : public less { bool operator()(PS x,PS y) { return x.second < y.second; // etc. } }; MYLESS mybad; PS* psArray = new PS[1000]; // array of PS // putting mybad to work... sort( psArray, psArray+n ); // default sort sort( psArray, psArray+n, mybad ); #include sort #include function objects #include “less”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.