Computer Science Fundamentals (CS153 2003S)
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Distributed: Monday, 28 April 2003
Due: 10 a.m., Monday, 5 May 2003
No extensions!
This page may be found online at
http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2003S/Exams/exam.04.html.
Contents
There are five problems on the exam. Some problems have subproblems. Each full problem is worth twenty-five points. The point value associated with a problem does not necessarily correspond to the complexity of the problem or the time required to solve the problem. If you write down the amount of time you spend on each problem and the total time you spend on the exam, I'll give you two points of extra credit.
You should answer only four of the five questions on the exam. If you answer five, I will choose which four to grade.
This examination is open book, open notes, open mind, open computer, open Web. However, it is closed person. That means you should not talk to other people about the exam. Other than that limitation, you should feel free to use all reasonable resources available to you. As always, you are expected to turn in your own work. If you find ideas in a book or on the Web, be sure to cite them appropriately.
Although you may use the Web for this exam, you may not post your answers
to this examination on the Web (at least not until after I return exams
to you). And, in case it's not clear, you may not ask others (in person,
via email, or by posting a please help
message) to put answers
on the Web.
This is a take-home examination. You may use any time or times you deem
appropriate to complete the exam, provided you return it to me by the
due date. It is likely to take you about five to ten hours, depending
on how well you've learned topics and how fast you work. You should
not spend more than ten hours on this exam. Stop at ten hours and write:
There's more to life than CS
and you will earn at least 80 points
on this exam. I would also
appreciate it if you would write down the amount of time each problem
takes. I expect that someone who has mastered the material and works at
a moderate rate should have little trouble completing the exam in a
reasonable amount of time. Since I worry about the amount of time my
exams take, I will give two points of extra credit to the first two
people who honestly report that they've spent at least seven hours on
the exam or that they've finished the exam. (At that point, I may then change the exam.)
You must include both of the following statements on the cover sheet of the
examination. Please sign and date each statement. Note that the
statements must be true; if you are unable to sign either statement,
please talk to me at your earliest convenience. Note also that
inappropriate assistance
is assistance from (or to) anyone
other than myself or our teaching assistant.
1. I have neither received nor given inappropriate assistance on this examination.
2. I am not aware of any other students who have given or received inappropriate assistance on this examination.
Because different students may be taking the exam at different times,
you are not permitted to discuss the exam with anyone until after I
have returned it. If you must say something about the exam, you are
allowed to say This is among the hardest exams I have ever
taken. If you don't start it early, you will have no chance of
finishing the exam.
You may also summarize these policies.
You may not tell other students which problems you've finished.
You may not tell other students how long you've spent on the exam.
You must both answer all of your questions electronically and turn them in in hardcopy. That is, you must write all of your answers on the computer, print them out, and hand me the printed copy with your name and the page number on every page. If you fail to write your name on every page, I will penalize you five points. You must also email me a copy of your exam by copying your exam and pasting it into an email message. Put your answers in the same order as the problems. Make sure that your solution conforms to the format for laboratory writeups (except that you should not specify the location of your file).
In many problems, I ask you to write code. Unless I specify otherwise in a problem, you should write working code and include examples that show that you've tested the code.
You should fully document all of the primary procedures (including parameters, purpose, value produced, preconditions, and postconditions). If you write helper procedures (and you may certainly write helper procedures) you should document those, too, although you may opt to write less documentation. When appropriate, you should include short comments within your code. You should also take care to format your code carefully.
Just as you should be careful and precise when you write code, so should you be careful and precise when you write prose. Please check your spelling and grammar. Since I should be equally careful, the whole class will receive one point of extra credit for each error in spelling or grammar you identify on this exam. I will limit that form of extra credit to five points.
I will give partial credit for partially correct answers. You ensure the best possible grade for yourself by emphasizing your answer and including a clear set of work that you used to derive the answer.
I may not be available at the time you take the exam. If you feel that a question is badly worded or impossible to answer, note the problem you have observed and attempt to reword the question in such a way that it is answerable. If it's a reasonable hour (before 10 p.m. and after 8 a.m.), feel free to try to call me in the office (269-4410) or at home (236-7445).
I will also reserve time at the start of classes this week and next to discuss any general questions you have on the exam.
Topics: Lists, Interfaces, Documentation
You may recall that I suggested that there are at least three basic kinds of lists:
Sort Orderdetermines the order in which the list elements are iterated.
As the definition suggests, sorted lists provide only the basic list operations; they just specialize those operations. How do you, as designer, indicate that the operations have been specialized? You write good documentation.
Design and document a SortedList interface and a
SortedListCursor interface.
Topics: Linear structures, Array-based implementations
Implement stacks using arrays. You need not document your stacks and you need not show me your testing (but you should test).
You need only implement the four central linear structure methods:
add, get, peek, and
isEmpty.
Topics: Exceptions, Java Basics
In their attempts to better understand exceptions, Carla and Carl
Caffeinated have decided to write a somewhat strange method that they
call antiExceptional. Their method calls another method.
If the called method throws an exception, their method increments a
counter. If the called method does not throw an exception,
their method throws an exception (and does not increment the
counter).
Here's what they've come up with.
public static int exceptionCount = 0;
public static void antiExceptional(Object param)
throws Exception
{
try {
sampleMethod(param);
throw new Exception("sampleMethod succeeded");
}
catch (Exception e) {
++exceptionCount;
}
} // antiExceptional
Unfortunately, it seems as if their method never throws an exception.
If sampleMethod fails, antiExceptional
increments exceptionCount and returns normally, which
is what they wanted. However, if sampleMethod succeeds,
antiExceptional also increments exceptionCount
and returns normally, which is not what they wanted.
Update the antiExceptional method so that it throws
an exception when sampleMethod succeeds (and only then).
Topics: Lists, Linked Structures, Java Basics
Most Java objects should provide four key methods:
String toString(), which converts the object to a
string;
boolean equals(Object other), which determines if
the other object is naturally equal to the object;
Object clone(), which creates a new copy of the
current object; and
int hashCode(), which generates a number for the
object to be used in hashing (equal objects must have equal
hash codes; unequal objects should have different hash codes,
but may have equal hash codes).
Implement these methods for the LinkedList class.
Note that another object is equal to a LinkedList if
it's a List and when you iterate the elements, they're the same.
Since we never completed the LinkedList class, you need
not write working code. However, your code should convince me that you
can write working code given sufficient time.
Topics: Linear structures, Trees, Sorting
Implement heapsort. You should build a
Heap data structure, insert the values from the
array to be sorted into the Heap, and then
read them back out in order.
You need not document this code (although you should).
The only methods you need to include for your heap are the constructor,
add, and get. You might also choose to implement
peek.
These are the errors observed by students. Since I have threatened to take off for grammatical or spelling errors, I give the whole class one point of extra credit for each such error they notice in this exam. Such extra credit is capped at five points.
sampleMethod(object) instead of
sampleMethod(param). [EC, 1 point]
antiExceptional is declared as boolean
but is really of type void. [ON, 1 point]
Here you may eventually find questions from your colleagues and my answers to those questions.
toString return for a list?seethe elements of a sorted list are through iteration, the only important aspect to an outsider is iteration.
add can mess up iteration of sorted lists
(e.g., if I add
an element smaller than something I've already visited), can I
note that add invalidates all cursors?add, and get.a2ps.
Sunday, 27 April 2003 [Samuel A. Rebelsky]
Monday, 28 April 2003 [Samuel A. Rebelsky]
Wednesday, 30 April 2003 [Samuel A. Rebelsky]
Saturday, 3 May 2003 [Samuel A. Rebelsky]
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[EC]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Lab Writeups]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Experiments in Java]
[Scheme Reference]
[Scheme Report]
[CS153 2002S (Walker)]
[CS151 2003S (Rebelsky)]
[CS152 2000F (Rebelsky)]
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue May 6 09:19:07 2003.
The source to the document was last modified on Tue May 6 08:12:57 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2003S/Exams/exam.04.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby