This is the home page for CMPSCI 240.
CMPSCI 240 is the second official offering of a new undergraduate core course
for the new computer science curriculum. It deals with counting,
probability, probabilistic reasoning, Markov processes, and touches on classical
game theory and information theory. For students
under the old computer science major requirements,
CMPSCI 240 may be used to fill the
"math elective" requirement. For students opting for the new requirements, it
is a required core course, though the requirement is waived for students who
have passed both CMPSCI 383 and another 300+ computer science elective.
(This page used to say that the requirement would be waived
for CMPSCI 383 and a "math elective" -- this is *not* a general policy.)

**Instructor Contact Info:**
David Mix Barrington, 210 CMPSCI
building, 545-4329, office hours Mon 11-12, Tue 11-12, Thu 1-3,
all in my office.
I generally answer my email fairly
reliably.

**TA Contact Info:** Brandon McPhail, mcphailb at cs dot umass dot edu,
office hours Monday 1-2, Friday 11-12, all in
220 LGRT.

The course is primarily intended for undergraduates in computer science and related majors such as mathematics or computer engineering. The main prerequisites are CMPSCI 187 (data structures) and MATH 132 (the second semester of calculus).

There is no professionally published textbook for the course. We will use draft versions of my discrete math textbook, which I will make available at Collective copies at cost. I'll announce here when the text booklet is available -- since I am editing and revising, it will be right before term starts. Note that course packets are not returnable, as you are paying for the copying costs only (I get no royalty).

The course is scheduled three lecture meetings a week, MWF 10:10-11:00 AM, and one discussion meeting per week, Wednesdays 11:15-12:05, all in room A201 of the low-rise portion of Lederle Graduate Reseach Center (LGRC, not LGRT). On three Wednesdays during the term we will use both the lecture and discussion periods for midterm exams. Some of the discussion periods have in-class writing assignments, for which you will not get credit if you are absent, but otherwise attendance is not part of the grade.

There will be three midterms, a final exam, four programming assignments, eight written non-programming homework assignments, and about four in-class writing assignments -- see the requirements page.

- Course Requirements and Grading
- Homework Assignment Directory (with #8)
- Programming Project Directory (with #4)
- Exam Directory (with final exam and solution)
- Questions and Answers on Homework (with some on #8)
- Corrections for the Textbook
- Syllabus

**Announcements (3 January 2010):**

- (3 Jan) I've now posted the final exam and its solution. I will have the exams in my office, and you may pick them up from me there if you like. Again, thank you all for a great semester.
- (21 Dec) I've now finished grading the final, and Brandon finished grading the projects despite being snowed in in NYC. The scale on the final was A = 105 and C = 70 as projected, and the twenty scores were 112, 109, 109, 105, 101, 98, 93, 89, 86, 84, 80, 79, 76, 73, 68, 64, 61, 58, 57, and 45. So five of you were below C on the final, but three of those five still got grades of C or better in the course because of other work. I have emailed individual exam and course grades to everyone who finished the course. I'll post the exam and solution when I get back -- in the meantime, enjoy your vacation! I enjoyed having you all in the course.
- (20 Dec) I've not yet finished grading the finals but might finish tonight. I won't be able to post the exam and its solution until I get back from my holiday travel on 30 December or so. But I will email each of you your final exam grade and overall grade as soon as I have it (I need one more set of grades from Brandon as well.) Your project grades and notes on your submissions are on the edlab servers for Project 3 and will be soon for Project 4.
- (15 Dec) My plan for the final exam is to have 50% of it on the last quarter of the course (since the third midterm) and 50% on the earlier parts of the course. Last spring's final is a pretty good guide to the format (except that I may have only four or five true/false instead of six) and content (except that the last week's material on information theory was not covered last spring).
- (15 Dec) I will leave HW#8 solutions to be picked up in the main office. You may also get HW#8 solutions and graded HW#8's in my office -- I will be around a lot this week. Brandon will hold office hours 11-12 on Friday in LGRT 220, just before the exam.
- (9 Dec) I've posted two questions and answers
on HW#8, although the second is really about Programming Project #4.
The first answer re-clarifies the statement of Problem 12.5.5 so it more
closely matches the actual play of
*Who Wants to Be a Millionaire?*, but since it is so late you may answer either the version on the HW#8 assignment page or the new one. - (7 Dec) I also have what I hope is a temporary email problem, so that I can read incoming email but not reply. I would email the system people to complain, but.... Anyway, if I haven't replied to your email I should be able to get to in tomorrow afternoon if not before.
- (7 Dec) As those of you in class today noticed, I am still not well with what is probably flu. I'm going to skip my office hours tomorrow but try to make the last two lectures on Wednesday and Friday. Wednesday's discussion will be the course evaluations, both the multiple-choice ones for the university and some essay questions for me. The latter will count as a discussion writing assignment, where any serious response will get a "check". So missing Wednesday's discussion brings a small grade penalty.
- (2 Dec) I've just posted the last HW assignment, which is due on the last day of classes (Friday 11 December) either in class or to the CMPSCI main office by 4:00 p.m. -- remember that the last programming assignment is also due that day, by 11:59 p.m. in your edlab directory.
- (2 Dec) I have what might be flu and so I will probably not be in for my office hours tomorrow. I'll be reading email.
- (25 Nov) Happy Thanksgiving! If you have HW#7 questions over the break, I am a better bet to answer them because Brandon will be traveling and/or offline for most of the weekend. See you Monday! By the way, we've fallen about a lecture behind, so Monday's lecture will be our treatment of both sections 12.5 and 12.6 -- a more superficial treatment than I had planned.
- (25 Nov) The Programming Project #4 assignment, which we presented in discussion today, is now posted. The skeleton code for this project and the solutions for Project #3 are now available on the edlab pages.
- (24 Nov) The correction was to Problem 12.3.3, not 12.2.3 -- I've also fixed it slightly today.
- (23 Nov) I've posted some questions and answers on HW#7 and also made a correction to Problem 12.2.3 on the HW#7 assignment page .
- (21 Nov) I've posted the solutions to the third midterm.
- (19 Nov) I've graded the third midterms and will return the graded papers in class tomorrow. I kept the scale at the advertised A = 90, B = 75, C = 60, D = 45. The 21 scores in sorted order were 99, 94, 90, 86, 85, 85, 80, 78, 78, 76, 75, 74, 73, 72, 70, 63, 62, 57, 50, 43, 43, for a mean of 72.5 and 17 grades of C or better. (There were a C-, a D+, and two D's.) I have posted the exam and will post the solutions soon.
- (17 Nov) I have posted the HW#7 assignment, which is due in class a week from Monday.
- (15 Nov) Actually those test results are for an extended feature set that includes all two-letter combinations as features. Brandon emailed the test results for the original feature set to everyone's edlab accounts.
- (15 Nov) HW#7 will be posted by the end of the day tomorrow, and will be due in class Monday 30 November, after Thanksgiving. HW#8 will be due Friday 11 December, the last day of classes, either in class or to the main office by 4:00 p.m. (so as not to burden the main office staff near closing).
- (14 Nov) Brandon thought it would be useful to post these test results for the first part of Project #3. If your code is correct, you should get exactly these answers. It's worth taking a look at which cities the NBC gets wrong -- several American cities with K's, for example, but not Knoxville.
- (6 Nov) Brandon is ill and must cancel his office hours for today.
- (4 Nov) I have posted the HW#6 assignment, which is due in class a week from Friday. Remember that Wednesday 11 November is a holiday and that our next midterm (on Chapter 11) is on Wednesday 18 November.
- (1 Nov) Last Friday in lecture I mentioned this newspaper contest where you are to identify the lyrics of
well-known rock songs after the words in them have been placed in alphabetical
order and duplicate words have been removed. Spam filters and search engines
often analyze a text only in terms of which words appear and which don't, so
these "normal form" lyrics represent what they would see in the original lyrics
in this case. The set of words in a text is often enough to determine what the
text is
*about*, but most of the meaning is lost, particularly in a short text. - (28 Oct) The web page for the Project #3 assignment is now up. I will fix up the project index page tomorrow.
- (28 Oct) Due to the construction in LGRC, another professor has a more compelling need for A201 LGRC in our office hour periods than we do. So my Monday office hours will be in my office, and Brandon's Friday office hours will be in LGRT 220.
- (28 Oct) The assignment for Project #3 was handed out on paper in class today -- I will post it soon, probably tomorrow.
- (28 Oct) I've made the first entry in the errata page, for the error I mentioned in class today on page 11-18.
- (28 Oct) The corrected solution code for Project 2 was not on the
edlab machines when I said it was on Monday, but it is now, in the directory
`/courses/cs200/cs240/cs240/proj2/answer/`

. - (25 Oct) The HW#5 assignment is posted, due a week from tomorrow, Monday 2 November.
- (25 Oct) There are a few more questions and answers on Project #2 now posted.
- (23 Oct) The second midterm and its solution are now posted.
- (23 Oct) A student found a mistake in the Project #2 assignment. I've corrected it, and put the question and answer here, in the question and answer folder. If I get more useful questions and answers on the project I will add them to that page.
- (22 Oct) I have graded the second midterms and will give them back
in class tomorrow. I set the scale at A=85 and C=55 -- it seemed to be a little
harder than the first midterm in terms of calculation (and the fact that
relatively few of you learned Markov/Chebyshev) and there was no extra credit.
Eight of the 26 students who took the exam scored below C, and three of them
have dropped the course. I am committed to doing what I can to get the other
five through.
There were six A's (98, 95, 95, 90, 89, 84), most of them A+'s of some kind, one A- (78), one B+ (75), three B's (72, 69, 68), one B- (65), three C+'s (62, 61, 59), three C's (57, 54, 53), two D's (41, 39), two D-'s (33, 33) and four F's (32, 31, 30, 29).

I will post the exam and solution tomorrow (possibly tomorrow night). Remember that Programming Project #2 is due on Monday at 11:59 p.m., and there is currently no homework due. I will post HW#5 over the weekend, and it will be due in class on Monday 2 November.

- (17 Oct) I'm back, and have posted some questions and answers from Brandon on HW#4. I'll be answering email tonight (Saturday) but not so much during the day tomorrow. (I will check in late tomorrow night.) On Monday I will wrap up the Chapter 10 material, including the Chebyshev Inequality and its application to the Coupon Collector's problem from section 10.9. Remember that the second midterm is Wednesday in class (both periods) and that there are practice exams linked from here.
- (9 Oct) I will be leaving for Germany midday tomorrow, and will not be back until Friday. Brandon will lecture on Tuesday (since it is a Monday schedule), Wednesday, and Friday, and will lead a discussion of Programming Project #2 on Wednesday. I will have some access to email but you should copy Brandon on any email inquiries about the project or homework.
- (9 Oct) The assignment for Programming Project #2. Brandon has posted code and test data on the edlab machines.
- (7 Oct) I've posted the HW#4 assignment, due a week from Monday, and the first question and answer on HW#3.
- (4 Oct) I've just posted HW#3, which is due
a week from Tuesday. (Remember that we have class that day because it is a
Monday schedule. The syllabus doesn't now show a lecture topic for that day
but I will fix that.) HW#4 will be posted soon and due Monday 19 October, so
you can have solutions in time for the second midterm on Wednesday 21 October.
Programming Project #2 is not yet up, but it will be due
*after*the second midterm. - (2 Oct) The solutions to the first midterm are now up.
- (2 Oct) The first midterm is posted, and solutions will follow later today. The 28 scores on the midterm were 110, 102, 100, 69, 92, 87, 87, 86, 81, 80, 76, 75, 75, 73, 71, 71, 71, 70, 69, 66, 64, 61, 59, 58, 54, 51, 48, and 41. The scale is 93 = A, 78 = B, 63 = C, 48 = D, 33 = F. The six people who scored below 60 should each talk to me at some point.
- (2 Oct) The University has set a time and place for our final exam. It will be on Friday 18 December 2009, 1:30-3:30 p.m., in room 142 of the Computer Science building.
- (1 Oct) I will have graded Midterm #1's for you in class tomorrow, and I will post the exam and its solution tonight or tomorrow. I'll post HW#3 sometime over the weekend -- it will be due Tuesday 13 October in class. (We have class that day because it is a UMass Monday.)
- (29 Sept) Here are the answers to the zipcode
problems: 100000, (14 choose 5) = 6006, (10 choose 5) = 252, 10*9*8*7*6 =
40240, 10000 + 10000 - 1000 = 19000, (5 choose 2) * 9
^{3}= 7290, 4^{5}= 1024, 1 + (6 choose 4) + (8 choose 4) + (10 choose 4) + (12 choose 4) = 1 + 20 + 70 + 210 + 495 = 796, 4000, 1000, 10*9*(5 choose 2) = 900. - (28 Sept) Brandon has written some practice induction problems and also provided solutions . I'll post solutions to the zipcode problems here tomorrow.
- (28 Sept) Don't worry if this makes no sense to you, but I did just have occasion to list all permutations of four elements over on my favorite political blog. A good thing there is so far not a fifth candidate in the primary!
- (26 Sept) I've answered some more questions on the
Q and A page, including a request for a hint on how to list Multisets, Sets,
and Perms recursively for the project. The hardest part of the project is
probably to list Perms recursively. Remember that if you are having trouble
with that, you can still answer the eight-queens problem (and
*maybe*the ten-queens problem) by using a simpler and slower method of listing Perms, such as listing all Sequences and throwing away the non-Perms. - (25 Sept) There are now some answered HW#2 questions on the Q and A page.
- (24 Sept) A reminder that you can find two midterms, with solutions, for the first quarter of CMPSCI 240 here. The exam this Wednesday will be similar in length and content to those two exams. You may want to read section 6.7 ahead of Monday's lecture, since it will be on the exam. Another useful study tool is a discussion exercise I ran last year -- here is PDF of the class handout.
- (21 Sept) There were a few minor mistakes on the HW#1 solutions that
were handed out on paper in class today:
- 10.1.1: The last term of the evaluation should be 0.4*0.6*0.6.
- 6.1.1: The evaluation should begin with "4", not "3".
- 6.2.3 (a): The solution misreads the question as "how many strings" instead of "how many such strings". The correct answer for k = 0, 1, or 2 is zero and for k=3 is 1.

- (20 Sept) I have posted the first question and answer on tomorrow's HW, and the second HW assignment, due a week from Monday in class.
- (17 Sept) I've now posted Programming Project #1, due a week from Monday, 28 September. If you have any problems logging onto and using the edlab, please clear them up this week so you have next week to work on the project. Paper copies of the project assignment were handed out yesterday in discussion.
- (17 Sept) Yesterday in lecture I mentioned a lecture by Guy Steele, one of the designers of Java, in which he illustrated as well as explained the idea of defining a rich language from a sparse set of primitives. That lecture is online and well worth watching. (The first ten minutes makes the point about definition, but the whole thing says a lot about why Java is the way it is.)
- (11 Sept) I have posted the first homework assignment, due a week from Monday. I've decided to have more frequent, shorter homeworks, which will be due about a week after they are assigned. This and other minor changes have been made on the requirements page.
- (9 Sept) The course packet is now ready at Collective Copies. It costs $25 (none of which goes to me) and is packet #44. It is the textbook for the whole semester. Note that it has little or no resale value, unlike conventional textbooks.
- (9 Sept) I have posted my office hours, which include 1-3 p.m. tomorrow.
- (8 Sept) See you in class tomorrow! I don't plan to use the discussion section, but I will stay in the classroom and answer any questions about the course or about academic advising in general. I have given the textbook masters to Collective Copies and they will have course packets ready on Thursday or Friday. I'll post the packet number, price, and time of availability here when I have it.
- (3 Aug) I've established the web page today. Many things about this course will be similar to last fall's offering of CS240, the web site for which is still up. The two main differences are the much larger enrollment this term, and three lectures on information theory that I am adding this term, at the expense of a few advanced topics in other areas.

Last modified 3 January 2010