CSC161 2011S Imperative Problem Solving
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
Assigned: Wednesday, 9 February 2011
Due: 11 p.m., Wednesday, 16 February 2011
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.
There are four problems on this examination. You must answer all of them. The problems are not necessarily of equal difficulty. Each problem may include subproblems. Four correct or mostly-correct solutions will earn you an A. Three correct or mostly-correct solutions will earn you a B. Two correct or mostly-correct solutions will earn you a C. One correct or mostly-correct solution will earn you a D. Zero correct or mostly-correct solutions will earn you an F. Failure to attempt the exam will earn you a 0. Partially-correct solutions may or may not earn you a partial grade, at the discretion of the grader.
Read the entire exam before you begin.
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. In particular, this exam is likely to take
you about five hours, depending on how well you've learned the topics
and how fast you work. You should not work more than eight hours on this
exam. Eight hours of work, documented attempts on all problems, and
a signed statement that There's more to life than computer science
will earn you at least a C on this exam.
I would also appreciate it if you would write down the amount of time each problem takes. Doing so may earn you a modicum of extra credit.
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 as restricted by 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. If you use code that you wrote for a previous lab or homework, cite that lab or homework and the other members of your group. If you use code that you found on the course Web site, be sure to cite that code. You need not cite the code provided in the body of the examination.
Although you may use the Web for this exam, you may not post your answers
to this examination on the Web. And, in case it's not clear, you may
not ask others (in person, via email, via IM, by posting a please help
message, or in any other way) to put answers on the Web.
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 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. You need not reveal the particulars of the dishonesty, simply that it happened. Note also that inappropriate assistance is assistance from (or to) anyone other than Professor Rebelsky (that's me).
You must present your exam to me in two forms: both physically and electronically. That is, you must write all of your answers using the computer, print them out, number the pages, put your name on the top of every page, and hand me the printed copy. You must also submit an electronic copy of your exam. You should create the electronic version by making a tarball of any relevant code and submitting that tarball on Pioneerweb. Failure to name and number the printed pages will lead to a penalty. Failure to turn in both versions may lead to a much worse penalty. Failure to turn in a legible version of the exam is also likely to lead to a penalty.
If your answer relies on provided files but you have not modified the files, you should include them in the tarball but should not include them in the printed copy of the exam.
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 do your best to format that code to GNU coding standards.
Unless I explicitly tell you to document a procedure, you need not document that procedure. If I do tell you to document a procedure, you should document it with six-P style documentation. If I do not tell you to document a procedure, you may still document that procedure and may use whatever form you find most appropriate.
Just as you should be careful and precise when you write code and 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 may give partial credit for partially correct answers. I am best able to give such partial credit if you include a clear set of work that shows how you derived your answer. You ensure the best possible grade for yourself by clearly indicating what part of your answer is work and what part is your final 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 each class before the exam is due to discuss any general questions you have on the exam.
Topics: Linux commands, Pipes
Suppose Professor L. stores information for his classes in the following form:
FirstName:LastName:Assignment:Grade:Notes
For example,
Jane:Smith:HW1:95 John:Doe:HW1:90 Joe:Smythe:HW2:100 Joe:Smythe:HW1:105 Jane:Smith:HW2:80 Jen:Doe:HW1:85 Jen:Doe:HW2:100 Jess:Smith:HW1:60 Jess:Smith:HW2:85 Jack:Smith:HW1:50 Jack:Smith:HW2:85 Jerry:Jones:HW1:80 Jo:Brown:HW1:84 Jeff:Doe:HW1:86 Jeff:Smith:HW1:87 Jeff:Jacobs:HW1:82 Jan:Jacobs:HW1:91
Write a Linux command (a pipe between various programs) that prints out the records for the five highest grades on HW1, sorted alphabetically by name (e.g., John Doe comes before Jane Smith but after Jen Doe).
You can assume that no two students have the same grade on the assignment.
Topics: Input processing, Numbers, Histograms, Loops
Write a C program, numbers, that extracts the numbers from
input and prints them out. For example, if the input was
The 411 on 3.1415 is that 11x11 is 121.
then the output should be
411 3.1415 11 11 121
Note: You should use getchar to read values, and not
scanf.
Topics: Strings, Characters, Output, Arithmetic Operations
In our initial explorations of output, we built a simple coding program
by adding 1 to each character. Let's develop a more complex version of
that program. Instead of using a single number, we'll use a code
word
. To encode an input, you add characters from the code word.
E.g.,
This is the text to be encoded + WordWordWordWordWordWordWordWo --------------------------------
So, the first letter of output will be the result of adding 'T'
and 'W'. The second will be the result of adding 'h'
and 'o'. The third will be the result of adding 'i'
and 'r'. And so on and so forth.
Of course, this strategy is a bit harder in C, since we need to deal with the limitations of ASCII representation. In particular, only characters with values between 32 (space) and 126 (tilde) are printable. So, one has to play a bit with the computation using modulo and other operations.
a. Write a C program, encode, that encodes its input using
a hard-coded code word. (You can use the code word of your choice.)
b. Write a C program, decode, that decodes its input
using the same hard-coded code word.
Topics: Output, Loops, Error Checking
Write a concise C program, diamond, that reads in an integer
and prints out a diamond made out of asterisks, such as the following.
* *** ***** ******* ***** *** *
The input integer represents the size of the edges. For example, the diamond given above has sides of size 4.
Your program should generate an appropriate error message if the user does not enter a valid side length.
Here you will find answers to questions of general interest. Please check here before emailing me your questions!
+3
or -235? [2011.02.09]3e4? [2011.02.09]foo123bar or
123a45 or 123.4elephants or even the
PITN My favorite number is 32. What's yours?My favorite number is 32.? [2011.02.14]atoi a good way to handle this problem? [2011.02.14]i) to keep track of where you
are in the keyword, incrementing and moding it at each step.4.1,
can we just read that as 4? [2011.02.10]pocket bread, you're really calling them a ...? [2011.02.10]
stdio.h? [2011.02.13]Here you will find errors of spelling, grammar, and design that students have noted. Remember, each error found corresponds to a point of extra credit for everyone. We usually limit such extra credit to five points. However, if I make an astoundingly large number of errors, then I will provide more extra credit.
If do not tell you ...should be
If I do not tell you .... [JN 2011.02.10, 1 point]
To, the first letter of output ...should be
So, the first letter of output .... [AA, 2011.02.12, 1 point]
Such as a the following ...should be
Such as the following .... [DU, 2011.02.13, 1 point]
Tuesday, 8 February 2011 [Samuel A. Rebelsky]
Wednesday, 9 February 2011 [Samuel A. Rebelsky]
Thursday, 10 February 2011 [Samuel A. Rebelsky]
Saturday, 12 February 2011 [Samuel A. Rebelsky]
Sunday, 13 February 2011 [Samuel A. Rebelsky]
Monday, 14 February 2011 [Samuel A. Rebelsky]
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Exams/exam.01.html.
Wednesday, 16 February 2011 [Samuel A. Rebelsky]
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Exams/exam.01.html.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazzza]
-
[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]
-
[Current Assignment]
[Current Lab]
[Current Reading]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
[Reference]
Related Courses:
[CSC195 2003S (Rebelsky)]
[CSC161 2009F (Coahran)]
[CSC161 2010S (Walker)]
[CSC161 2010F (Rebelsky)]
Misc:
[SamR]
[ISO]
[GNU Coding Standards]
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 Sun Feb 20 13:46:43 2011.
The source to the document was last modified on Sun Feb 20 13:40:33 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC161/2011S/Exams/exam.01.html.