CMPSCI 187: Programming With Data Structures
David Mix Barrington
This is the home page for CMPSCI 187.
CMPSCI 187 is the second course in programming for undergraduate
computer science majors and deals with the design, use, and analysis
of important data structures, implemented in Java.
Instructor Contact Info:
David Mix Barrington, 210 CMPSCI
building, 545-4329, office hours for Fall 2012
Monday 2:30-3:30, Tuesday 4-5, Thursday 2:30-3:30, all in my office.
I generally answer my email fairly
TA Contact Info:
If you have a question that either I or any of the TA's
might answer, send it to
firstname.lastname@example.org and we will all see it.
Jackie Feild, email@example.com, office hours
Tuesday 1-2 in LGRT 223;
Ravali Pochampally, firstname.lastname@example.org, office hours
Thursday 6-7 in LGRT 223;
Jen Steshenko, email@example.com, office hours
Friday 2:30-3:30 in LGRT 223;
and Hannah Blau, firstname.lastname@example.org, office hours
Wednesday 6-7 in LGRT 223.
The course is primarily intended for undergraduates in computer science
and related majors such as mathematics or computer engineering. CMPSCI 121
(an introduction to Java programming) is a prerequisite. There is no formal
mathematics prequisite but readiness for MATH 131 (Calculus I for scientists
and engineers) is recommended.
The course meets for three lecture meetings a week, Monday, Wednesday,
and Friday, at 1:25-2:15, in Morrill I room N375. (This room is at the northeast corner of the Morrill complex, accessible from Stockbridge Road.)
There is one discussion meeting per week, meeting on Wednesdays before
There are four separate discussion sections, each to be led by one of
the TA's, meeting 9:05-9:55, 10:10-11:00, 11:15-12:05, and 12:20-1:10. Check
SPIRE to see which discussion you are in -- with rare exceptions, I want you
to go to the one you are assigned. These discussion sections will meet in
the CMPSCI computer lab in rooms 223 and 225 of the Lederle Tower (LGRT) --
room 225 is accessible only through room 223. Note
that discussion sections did not meet on the first Wednesday of
the semester, 5 September.
Most discussions will have a written assignment which you
will carry out in pairs, chosen by you at the start of each discussion with
the requirement that you may not have the same partner twice in the term.
Most assignments will involve use of the computers that are in the lab, with
each pair using a single machine.
Discussion attendance is required,
so that missing a discussion
will incur a grade penalty. It is intended that the four discussion sections
be as interchangeable as we can make them.
The textbook is a new one for this term, the third edition of
Object-Oriented Data Structures Using Java by Dale, Joyce and Weems
(Jones & Bartlett, ISBN 978-1-4496-1354-9), henceforth called "DJW"
The first and second
editions of the book are substantially different and will not do. Lectures
will follow the book fairly closely (especially after the first few weeks)
but I will also make slides from the lectures available on this site.
The DJW book is not a Java language manual. There are a
variety of ways to get information about the Java language -- two I like are
the official API's
for the language and the very inexpensive book Java Precisely by Peter Sestoft. Java
Precisely is intended more as a reference for people who already know the
language, but it has both all the details you aren't likely to ever memorize and
a very clear definition of exactly what the language is and what it does.
Announcements (21 December 2012):
- (21 Dec) I've finished grading the finals and filed the grades.
Given the number of you, I'm not going to email grades to people -- they should
be available on SPIRE by 28 December.
The final exam had a high of 107, a low of 24, and a median of 65. I put
the A level at 95, B at 80, C at 65, D at 50. There were 4 A+ finals, 8 A's,
7 A-'s, 13 B+'s, 6 B's, 9 B-'s, 11 C+'s, 15 C's, 12 C-'s, 11 D+'s, 14 D's, and
The overall grades were generally better than the finals, because of the
programs and discussions. Of the 132 people who took the final, the grade
distribution was as follows: 3 A+'s, 7 A's, 11 A-'s, 15 B+'s, 18 B's, 15 B-'s,
22 C+'s, 24 C's, 8 C-'s, 6 D+'s, 2 D's, and 1 F. Those with final grades below
C will not be allowed to go on to 200-level core courses in spring.
I will post the exam and solution but I won't get to it til after I
get back from my Christmas holiday.
- (9 Dec) PDF slides for the final exam review are
- (9 Dec) The review session for the final exam will be
Monday 10 December, from 1:30-3:00 in room 151 of the Computer
Building. I'll post my slides from the review here when I have
The format of the final will be similar to the practice and real
finals from Fall 2011 linked from this
The individual questions on those exams often reference last year's
textbook and projects, but the length and difficulty of these year's
questions will be similar. Note that full solutions are linked from
the same page.
- (7 Dec) I've just posted a
lecture are up.
- (5 Dec) Various students are reporting different numbers for
the various word counts in
report.dat, even using the
Federalists.dat file linked to below. This
appears to be due to different file formats and translations done in
the course of moving the files. If this is the only problem with
PQFrequency class, don't worry too much about it. (But
if your code doesn't compile (on the edlab machines), run,
and get essentially the same output that we do, you do
have a problem.
- (5 Dec) Ok, along with some more material on the
q&a page for Project #5, we also have
a output file from running DJW's
code (modified to have the right input and output) on the Federalist
Papers from Project Gutenberg -- the exact input file we used is
should have the same output if called on that input file.
- (3 Dec) Notes for Wednesday's
lecture are up. These include some material on selection
problems, which is not in the textbook.
- (2 Dec) Notes for tomorrow's
lecture are up.
- (30 Nov) Notes for the Friday
lecture are now up, as are several more questions and
answers on Project #5.
- (27 Nov) I cannot hold my office hours 4-5 today because of a
department seminar. I'll be available between 3 and 4 instead.
- (27 Nov) Wednesday's lecture
notes are up.
- (26 Nov) Today's lecture notes
are up. Wednesday's will follow later tonight.
- (20 Nov) I have started a q&a page for Project
#5 and will update it as I get more questions (but probably not much over
- (19 Nov) The lecture notes for
Wednesday are now up.
- (19 Nov) Lecture #29 is now up.
- (18 Nov) I have posted the Project #5
assignment, due on Friday 7 December, the last day of classes.
There is no Project #6, though one page on this site suggested there
might be. I will post lecture notes for tomorrow later tonight --
that lecture will say a lot about the project.
- (16 Nov) A reminder about next week's schedule. Thanksgiving
on Wednesday at 5:00 pm, so Hannah's Wednesday evening office hours are
cancelled and everything is cancelled on Thursday and Friday. There is
a discussion Wednesday morning and a lecture Wednesday afternoon. If your
travel plans make it impossible for you to come to discussion, let me know and
I can excuse you from it.
- (16 Nov) I've just posted tomorrow's (well, today's) lecture slides. I'll try to be better at
getting these up in advance. I do plan to give back exams tomorrow
-- as of now (12:15 am) I only have to grade questions 6 and 7 on
fifteen more of them. I will try to get to the classroom as soon as
the previous class is out of there.
- (13 Nov) I have posted the notes
for tomorrow's lecture. Remember that there is no discussion
because we are on a Monday schedule. I will have my 2:30-3:30
- (11 Nov) I have posted a copy of the exam
and a preliminary solution. (Link
to preliminary solution fixed 12 November.) I will probably not
have the exams graded by Wednesday but will be able to say something about the
- (8 Nov) The slides for tomorrow's lecture
are up. Sorry I didn't get to these very far in advance. Remember that next
Monday is a holiday and that next Wednesday is a Monday. So on 14 November
there will not be discussion, there will be lecture, and I will have office
hours from 2:30-3:30.
- (7 Nov) The slides for today's
midterm review are now avaiable.
- (7 Nov) I am posting Ravali's solution
to Project #4.
- (4 Nov) The slides for Lecture
#25 are now up. Remember that tomorrow, we will lightly cover
both Lectures #24 and #25, because we lost last Monday.
- (4 Nov) I will be away from campus and off email all day Tuesday, and must
cancel my office hours that day. I will be in New Hampshire working
for the candidates of my choice, and I urge you to vote for the
candidates of yours if you are eligible.
- (2 Nov) A grading driver for Project #4 is posted here.
- (1 Nov) I've posted a solution for Project
#3. This solves only the revised Project #3, but since I made it by taking
out methods from a solution to the original Project #3, you may get some
ideas about what fields and what methods to put in your Project #4 to get the
original Project #3 methods to work.
- (1 Nov) I have to move my office hours today from 2:30-3:30
to 3:00-4:00. Sorry for the late notice -- I tried to email you all but
SPIRE would not let me.
- (30 Oct) I've posted some questions and
answers on Project #4, which is due on Monday. I'll add to this page
as more questions come up.
- (28 Oct) The University has cancelled all classes tomorrow,
so our lecture (and all office hours) are cancelled tomorrow. If we
back in business by Wednesday, we will have the discussion I
which involves binary search. Please read Section 6.6 and/or read
Lecture 22 notes. I'll give Lecture 22
the next lecture we have. I'll put up notes for the lectures on the
original schedule -- if we lose just tomorrow I'll give 22 on
23 on Friday, and a summary of 24 and 25 on Monday 5 November.
- (28 Oct) Next Wednesday's lecture
is up. The
plan for possible weather disruptions next week is simple -- if the University
closes (see here) for any part of
a lecture, the lecture is cancelled. If it is closed for any part of the period
from 9:05 to 1:10 on Wednesday, then all four discussion sections are cancelled.
If we lose lecture time, then portions of Lecture #24 and #25 will not be on
the test -- I will know about this for sure by next weekend. If you cannot get
to class safely, then stay home -- we have no deadlines during next week except
for the discussions if they happen.
- (26 Oct) Next Monday's lecture is up.
- (25 Oct) The Project 4 assignment is up,
due a week from Monday.
- (25 Oct) Tomorrow's lecture notes are
finally up -- I hope to get next week's up before or during the weekend.
- (24 Oct) I've just added a few more questions and answers
to the Project 3 Q&A page. Remember that we are
no longer giving a 48-hour grace period for submission problems --
by now we expect you to have your project code on the EdLab machines by
the deadline, and that you have tested it in the EdLab environment with
our driver. I'll be on-line for email later this evening, but I won't
guarantee to answer anything sent after 11:00 pm.
- (23 Oct) I've just posted a revised
version of the driver for Project #3, which tests only the functionality
required for that project.
- (22 Oct) Because I want to see grades on Project #3 that are
a lot better than the grades for Project #2, I am changing
assignment. What is due on Wednesday is now only the first
task of the project as it was listed, to create the
continentMap method. Those of you who have made
progress on or even finished the other two tasks, though, are in
great shape because you have now done much of Project #4, to be due
on 5 November. There is also now a grading driver for all three
tasks. (Note that it expects methods named
continentTable, so if you want to test it just on
continentMap you will need stub methods with these names.)
- (21 Oct) The lecture notes for tomorrow
are up, and I hope to have the Wednesday and Friday notes up tonight.
- (16 Oct) Greetings from Germany. At some point I seem to have
lost the link from this page to the discussion assignment directory.
I've just put it back now. It has links to material to be
used tomorrow in discussion.
- (12 Oct) It may be a while before I get to put up HTML versions
of the first midterm and solution. So I am posting the PDF
of the exam and a text file with the solution.
I'll put up the others after I am done with the grading. I've now graded
almost half of them -- so far I think I'm putting the scale at A = 90, C = 60,
and the high is 98 (twice), the median is 67 (a high C+), and the low is 28
though there are only a few below 50.
- (12 Oct) The Project #3 assignment
is up, due a week from Wednesday which is 24 October. There are two
tasks, the first of which you now know everything about and the second
of which uses queues, which you will see next Wednesday (or in DJW, or
in the lecture slides which are already up).
- (10 Oct) Our final exam has been scheduled for 4-6 p.m. on
Thursday 13 December, in Marcus room 131. The second midterm on
Wednesday 7 November will also be in Marcus 131.
- (9 Oct) Again, tonight's exam is in Goessman from 7-9 p.m. --
go to room 20 if your last name begins A-L, to room 64 if it begins M-Z.
- (8 Oct) I have posted the slides for tomorrow's review session,
which mostly consist of questions from last year's exams. I have also posted
the lecture slides for this week and next week. Remember that next
(15-19 October) I will be away. There is no lecture Monday 15
October, and James Allan will deliver guest lectures on Wednesday 17
and Friday 19 October. There will be a discussion that week.
- (8 Oct) I plan to post the Project #3 assignment on
It will be due on Wednesday 24 October at 11:59 p.m.
- (7 Oct) I have posted solutions for
Project #2. If for some reason you have not yet handed in Project
make very sure you don't see these and then hand it in...
- (5 Oct) I am extending the deadline for Project #2
by 24 hours, to 11:59 tomorrow night, Saturday 6 October.
The model solution will be available sometime on Sunday.
I will not guarantee responses to the cs187help mail address,
however, after 10 p.m. tonight.
- (3 Oct) I have just corrected some errors in the
driver for Project #2
which prevented it from compiling. I think it is right now, please
let me know if it is not. Thanks to the students who pointed out
- (1 Oct) Update on Project #1 grades: apparently the "grade"
text files can be read only by the TA's who created them. I hope
will be corrected soon and I will let you know when it is.
- (1 Oct) I have just posted an untested driver for
Project 2 here. I also
expect to be adding several questions and answers to the Q&A for Project 2 tonight.
- (1 Oct) The exam a week from tomorrow will be held in
both Goessman 20 and Goessman 64, from 7-9 PM. There
will be one TA in each room. If people with last names beginning
A-L go to room 20 and those beginning M-Z go to room 64, it ought to
more or less work out.
- (1 Oct) MassPIRG has asked me to once again remind you to
register and vote if you are eligible, and to point you here
if you need any assistance in doing so.
- (30 Sept) The lecture notes for the coming
week are now posted, in PDF form only.
- (29 Sept) I have started a Q&A page
for Project 2, which includes some
substantial clarifications of how your code should interface with
our driver (which we will get to you at some point).
- (29 Sept) Some announcements from yesterday's lecture you
might have missed:
- Please be on time for discussions -- losing the first ten
minutes of a 50-minute period does serious damage to our plans.
- Your grade for Project #1 will at some point appear as a text
file called "grade" in your "proj1" directory. The directory
called "proj1_grade" in your "cs187" directory, which you can't
read, was made by our grading script to have a place to test your
code -- you don't need to see it. We hope to have all the grades
in place by Monday.
- The first exam is a week from Tuesday evening, as it
says on the syllabus. As it also says
there, a week from Tuesday has a Monday schedule -- during our
lecture period that day I will have an optional review session in
the normal classroom. If you have a conflict with the exam time
of 7-9 p.m., please email me as soon as possible.
- (26 Sept) Notes for this morning's discussion, together with
a solution and a link to the five-letter word file, are
here. Also, Project 2
is now officially released, due on Friday 5 October.
- (26 Sept) A solution to Programming Project #1 is
here. This class contains the additional
method to load the object from a text file, which is used in
- (25 Sept) Please note that if you plan to miss tomorrow's discussion
because you are observing Yom Kippur, you can email me and me marked "excused".
This is the general policy for all religious holidays. You are responsible for
learning about what you have missed.
- (24 Sept) The Learning Resources Center in the library has free tutoring
available for CMPSCI 187 -- their schedule of hours is
here. We have not yet talked to their tutors about
any specifics, but they will have hired people who have done well in CMPSCI
187 or ECE 242 in the past.
- (23 Sept) Next week's lecture notes are up as PDF's, for
- (23 Sept) A draft version of the Project #2
assignment is up. I will make it official in a day or two.
- (21 Sept) Discussion #3 and Project #2 will use code from the DJW
book. You should (before Wednesday) follow the instructions on page 28 of
DJW to put their code on your machine. There may be complications with getting
that code to the right place on your machine, especially if you are
using Eclipse or another IDE, but we are working on advice to deal with that.
- (21 Sept) Remember that you must resolve any problems you have
with Project #0 before you can hand in Project #1. Thus if you have
outstanding Project #0 problems Monday at midnight, you get an F on Project #1.
(Of course there may be rare special circumstances.) The TA's have notified
everyone with problems, so if you have no email from them you are ok.
- (21 Sept) The purpose of Project #0 was to avoid the kinds of small
errors that make it difficult or impossible for us to grade your projects.
If such an error (e.g., a submission in an incorrectly named directory)
happens on one of the graded projects, a TA will email you saying that your
submission can't be graded. You then have 48 hours from the time of the email
to fix the problem. If we do we will grade your project and deduct one letter
grade (e.g., from B to C). This rule is not intended for you to have extra
time for subsequent work -- we expect that what you submit is essentially what
you had ready at the deadline.
- (21 Sept) I have corrected the link below to the driver for Project #1.
- (20 Sept) A driver for Project #1
is now available. Working with this driver is a necessary, but not sufficient,
condition for your StringBag class to be correct. (Link fixed at 3:30
p.m. 20 September.)
- (19 Sept) I have posted discussion notes for
Discussions #1 and #2.
- (18 Sept) Some of you (we'll figure out how many)
have missed our "deadline" for Project 0.
Our priority is to get you through this hurdle as soon as possible, so that
you can submit Project #1 by Monday. The best way to solve your problem is
probably at a TA office hour -- I will do what I can in my own office hour as
well. But the responibility for figuring this out is yours -- we will not
accept "I can't log into the edlab" as an excuse for Project #1, even as a
reason for an extension.
- (18 Sept) I have posted the first few questions
and answers on Project #1. I will add to this list through the week.
- (18 Sept) Since Apple no longer stores Keynote presentations
as single files, I am for now giving up on making the lecture notes available
as .key files. You can still get the lecture notes as .pdf files, which is
what most or all of you have been doing.
- (16 Sept) The PDF lecture notes for lectures 6 and 7 are up.
There is some problem with the Keynote versions. I should have lecture
8 up, at least in PDF, later tonight.
- (13 Sept) I think we mentioned this in most or all of the discussions
yesterday, but if you want to change your password on the EdLab you must use
the command "yppasswd" instead of the old Unix standard "passwd".
It will prompt
you for both the old and new one.
- (13 Sept) You may now consider the Project #1
assignment official -- it is due a week from Monday.
- (12 Sept) I have posted office hours for the four TA's above.
Note that their office hours are in the lab we use for discussions, LGRT
223, while mine are in my office, room 210 CMPSCI building.
- (11 Sept) Here is a handout
for tomorrow's morning discusssion.
- (10 Sept) Today in lecture I said some things about how to
the EdLab and submit your assignment. This will be among the topics
of Wednesday's discussion, but here is a summary of what I said.
You each have an EdLab account, with a username the same as your OIT
username. (Students who entered the class late may have to wait a
to get accounts.) You can access EdLab machines using the "ssh"
(from a Linux or Mac machine), or utilities such as "putty" and
from a Windows machine. There is some information on how to do this,
and some pointers to pages on these utilities, at
the EdLab's main page.
There is a rule to generate your default password which I
described in lecture today but am not
to put on a public web page. We'll also review this in discussion.
you have an EdLab account already but have forgotten the password,
- (10 Sept) I've made some changes to the draft
Project 1 -- I'm waiting for some more
before officially releasing the assignment.
- (10 Sept) This course carries an "R2" General Education designation,
though nearly all of you already have an R2 from CMPSCI 121 or a mathematics
course. I have just learned that I am required to have a
statement in my syllabus about how the course meets
the goals of gen-ed as set out by the General Education Council. I have done
so, and you may read it if you like.
- (9 Sept) The next three lecture notes are up,
covering the coming week. A draft of the the first
programming project is also up, though this will not be the official
version for a day or two.
- (8 Sept) The first programming
project (actually the zeroeth project) is now posted. This is
due a week from Monday and is mainly designed to check that you have
mastered the procedure to submit work to us through the
EdLab. We'll give you
edlab passwords in lecture Monday and in discussion Wednesday.
- (5 Sept) My office hours for this semester are Monday 2:30-3:30,
Tuesday 4-5, and Thursday 2:30-3:30.
- (3 Sept) I have created the lecture notes
directory and posted the slides for this weeks lectures,
#2. Remember that you may download
these either as Apple Keynote (.key) or ordinary .pdf files.
- (3 Sept) Remember that discussion sections do not
meet this Wednesday, 5 September. I will be in my office 10-11 and
that day for general office hours -- we should figure out general
office hours soon.
I have a few spaces left in the course and am handling them
directly (not through SPIRE) so I can give them to the most
deserving. If you are not registered and want to join the course,
chances are best if you have already contacted me or Darlene Fahey,
the undergraduate administrator. But you can still contact me and
come to the first lecture on Wednesday at 1:25.
Any student who misses both the first two lectures may be
out of the course to make room for someone else. The way I will
handle this is as follows: At those two lectures there will be
"information sheets" which you should take and return to me,
answering a few brief questions. If you are registered and I don't
have a sheet from you by the end of Friday's lecture, I may kick you
If you are not registered and want in, make sure that I also have a
- (8 Aug) I have posted the syllabus, though note that almost all
the discussion activities are "TBA", meaning "to be announced". I have
also posted the course requirements and grading
- (8 Aug) It looks like we may not be able to accommodate all the
demand for the course, even with our expanded size. If you want the course
and cannot add it on SPIRE, please email Darlene
Fahey and she will add you to the list of those wanting in. We won't know
finally how many we can take until the second week of class.
- (25 July) Note that the discussion sections will not meet on
the first day of the course, Wednesday 5 September. We will begin the course
with that day's lecture at 1:25.
- (25 July) This section of the main page will serve as a blog for course announcements.
Please check it frequently -- you are responsible for what is here and I will
use broadcast email only for emergencies. Today I have put up the main page,
and in the next day or two I plan to put up the syllabus and the requirements
and grading page.
I taught this course a year ago and you can read the entire
website for the Fall 2011 version -- it has exams,
solutions, lecture slides, and programming assignments. This offering of the
course will be similar to that one, except that: (1) the textbook has changed,
(2) we have a somewhat larger class, (3) we have four discussion sections
instead of two, and (4) we have access to machines during the discussion
Last modified 1 January 2013.