Fundamentals of Computer Science 1 (CS151 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]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Scheme Reference]
[Scheme Report]
[CS151 2003S Gum]
[CS151 2002F]
[CS151 History]
[SamR]
Distributed: Wednesday, 19 February 2003
Due: noon, Friday, 28 February 2003
No extensions.
This page may be found online at
http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2003S/Exams/exam.01.html.
Contents
Useful Files
There are seven problems on the exam. Some problems have subproblems. Each full problem is worth fifteen 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.
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 three to six hours, depending on how well you've learned topics and how fast you work. I would 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 three points of extra credit to the first two people who honestly report that they've spent at least five hours on 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 in a printed version of your exam. That is, you must write all of your answers on the computer, print them out, number the pages, put your name on every page, and hand me the printed copy. 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 confirms to the format for laboratory writeups (except that you should not tell me the location in the MathLAN or on the Web, since your code should not be published).
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 document all of our primary procedures. In most cases, a few sentences will suffice. In a few cases, I'll ask you to provide the full documentation (including parameters, purpose, value produced, preconditions, and postconditions). If you write helper procedures (and you may certainly write helper procedures) you should document those with a few short notes. 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 in documentation, 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'll be gone from noon Friday to 5 p.m. Sunday, so don't call during those times.]
I will also reserve time at the start of classes next week to discuss any general questions you have on the exam.
Key Topics: Predicates
Write a procedure, simple?, that determines if a value
is simple (that is, a number, a symbol, a character, a Boolean
value, or a string).
> (simple? 'a) #t > (simple? (list 'a)) #f
Key Topics: Lists
As you know, car takes a list and returns the first element of
that list and cdr takes a list and returns all but the first
element of the list.
Write two procedures, last and all-but-last,
that do something similar, but at the end of the list. In particular,
last should return the last element of a list; and
all-but-last should return all but the last element of a list
For example,
> (last (list 1 2 3)) 3 > (all-but-last (list 1 2 3)) (1 2) > (last (list 'a 'b 'c 'd)) d > (all-but-last (list 'a 'b 'c 'd)) (a b c)
Key Topics: Lists, Simple Values
Some of you have asked for a more general version of append
that permits one or more of the parameters to be a simple value (a
symbol, number, string, character, or Boolean value). Let us call that
more general version join.
join is presented with two lists, it appends them
using append.
join is presented with a simple value and a list as
parameters (in that order), it prepends the value to the list.
join is presented with a list and a simple value as
parameters (in that order), it puts the value at the end of the list.
join is presented with two simple values as
parameters, it puts them into a list.
For example,
> (join (list 1 2 3) (list 'a 'b)) (1 2 3 a b) > (join null (list 'a 'b)) (a b) > (join 1 (list 'a 'b)) (1 a b) > (join (list 1 2 3) 'a) (1 2 3 a) > (join 1 'a) (1 a)
Define join.
Key Topics: Numeric Computation
Here are two procedures that compute the roots of the quadratic aX2+bX+c.
(define quadratic-root-one
(lambda (a b c)
(/ (+ (- b) (sqrt (- (* b b) (* 4 a c))))
(* 2 a))))
(define quadratic-root-two
(lambda (a b c)
(/ (- (- b) (sqrt (- (* b b) (* 4 a c))))
(* 2 a))))
At times, the quadratic formula has only one real root, which means the two procedures return the same value. For example,
> (quadratic-root-one 1 -2 1) 1 > (quadratic-root-two 1 -2 1) 1
At times, the quadratic formula has two real roots. For example,
> (quadratic-root-one 1 -3 2) 2 > (quadratic-root-two 1 -3 2) 1
At times, the quadratic formula has no real roots. For example,
> (quadratic-root-one 1 0 1) 0+1i > (quadratic-root-two 1 0 1) 0-1i
Write a procedure,
(number-of-real-roots a b c),
that determines how many real roots
aX2+bX+c has. Your procedure
should not call quadratic-root-one or
quadratic-root-two. Rather, you should be able to
compute the number of roots by looking at a certain subformula
of quadratic.
Key Topics: Numeric Computation
Document (using the six P's) and write a procedure, (approx val digits) that approximates
val to digits places after the decimal point.
You can assume that digits is less than 10.
For example,
> (approx 1/3 3) 0.333 > (approx 2/3 5) 0.66667 > (approx 22/7 2) 3.14 > (approx 22/7 0) 3.0 > (approx 1.9999999 4) 2.0
Key Topics: Strings, Conditionals
Write a procedure, (a-or-an singular-noun-phrase),
that takes a string as a parameter and prefixes the appropriate indefinite
article. For example,
> (a-or-an "aardvark") "an aardvark" > (a-or-an "baboon") "a baboon" > (a-or-an "incredibly appropriate exam") "an incredibly appropriate exam" > (a-or-an "problem that students should have solved on homework 2") "a problem that students should have solved on homework 2"
Key Topics: HTML, Strings, Conditionals
Write a procedure, (markup tag str) that
usually surrounds str with the specified HTML tag. However,
if str is empty, markup should return just the
singleton tag named tag.
For example,
> (markup "p" "Hello.") "<p>Hello.</p>" > (markup "br" "") "<br>"
These are some of the questions students have asked about the exam and my answers to those questions.
a-or-an have to handle special cases like
an F?
Here you will find the errors of spelling, grammar, and external design.
(simple (list 'a)).
[YP, 23 Feb. 2003]
pruposeinstead of
purposein the Q&A section. [NL, 23 Feb. 2003]
[A] few sentences will sufficeI wrote
suffices. [NL, 23 Feb. 2003]
join (it was implicit).
[YP, 23 Feb. 2003]
Tuesday, 18 February 2003 [Samuel A. Rebelsky]
Wednesday, 19 February 2003 [Samuel A. Rebelsky]
Monday, 24 February 2003 [Samuel A. Rebelsky]
Thursday, 27 February 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]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Misc:
[Scheme Reference]
[Scheme Report]
[CS151 2003S Gum]
[CS151 2002F]
[CS151 History]
[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:22:17 2003.
The source to the document was last modified on Tue Apr 1 22:57:54 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2003S/Exams/exam.01.html.
;
;
Check with Bobby