Final Exam
CS 201, Fall 2008
You have 150 minutes.
Show your work and explain all of your answers. Good work often earns partial credit. A correct
answer with no explanation often earns little or no credit.
When asked to explain something, explain with as
Exam 3 Answers
CS 201, Fall 2010
Compare our various sorting algorithms. Which is best?
Answer: Merge sort is (n log n), but requires a lot of extra space. Quicksort is (n log n)
if the pivot is chosen carefully (e.g. using the selection algorithm), but c
Exam 2
CS 201, Spring 2009
This exam begins for you when you open (or peek inside) this packet. It ends at 11:59 PM
on Thursday 2009 May 21. Between those two times, you may work on it as much as you like. I
recommend that you get started early and work o
Exam 2 Answers
CS 201, Fall 2010
In the AVL trees below, keys are shown but values are not. Following our standard algorithm,
insert the key 5 into the following AVL tree and restore balance.
Answer: [After insertion, node 2 is out of balance in the RR se
Exam 2
CS 201, Fall 2010
You have 60 minutes.
Show your work and explain your answers. Good work often earns partial credit. A correct
answer with no explanation often earns little or no credit.
If you are asked to write code but you do not know the exact
Exam 2
CS 201, Fall 2008
This exam begins for you when you open (or peek inside) this packet. It ends at the start of class
on Monday 2008 November 3. Between those two times, you may work on it as much as you like. I
recommend that you get started early
Exam 1 Answers
CS 201, Fall 2010
Im going to ask you two unrelated questions about our gcd function from class:
def gcd(a, b):
"The arguments a and b are integers with a >= b >= 0. Returns the greatest
common divisor of a and b."
if b = 0:
return a
else:
Exam 1
CS 201, Fall 2010
You have 60 minutes.
Show your work and explain your answers. Good work often earns partial credit. A correct
answer with no explanation often earns little or no credit.
If you are asked to write code but you do not know the exact
Exam 1
CS 201, Spring 2009
1. Ill give two answers. The rst answer begins with Queue, as implemented in class, with
constant-time enqueueing and dequeueing. We can dene RoundRobin as a subclass of Queue,
with methods
def add(self, obj):
self.enqueue(obj)
Exam 1
CS 201, Spring 2009
You have 70 minutes.
Show your work and explain all of your answers. Good work often earns partial credit. A correct
answer with no explanation often earns little or no credit.
If you are asked to write code but you do not know
Exam 1
CS 201, Fall 2008
You have 70 minutes.
Show your work and explain all of your answers. Good work often earns partial credit. A correct
answer with no explanation often earns little or no credit.
If you are asked to write code but you do not know th
Exam 1 Answers
CS 201, Fall 2008
1. To refresh your memory, UnorderedList has methods isEmpty(), length(), add(), search(),
and remove(), in addition to the constructor. In our implementation from class we had to recompute the length every time the user a
Exam A Solutions
CS 111, Spring 2012
A.
a. player: String (str).
b. hasWon: Function (function).
c. m: List (list). (The list contains two integers. In some cases, m is None, which has the
type NoneType. But I did not insist on this level of detail, when
Exam B Solutions
CS 111, Spring 2012
A. The kernel [-1, -2, 0], [-2, 0, 2], [0, 2, 1] works. (This is not the only way to
answer this question. In general, we probably want zeroes along the diagonal, positive numbers
below the diagonal, and negative numbe
Exam 1
CS 111, Winter 2010
You have 60 minutes.
Show your work and explain your answers. Good work often earns partial credit. A correct
answer with no explanation often earns little or no credit.
If you are asked to write code but you do not know the exa
Exam 1 Answers
CS 111, Winter 2010
0. [Students did well on this with various answers, so Ill omit my answer.]
1A. Here are short implementations.
def encipherRot13(s):
return encipherRepeatedPad(s, N)
def encipherCaesar(s, p):
return encipherRepeatedPad(
Quiz
CS 202, Winter 2013
Carleton College CS 202, Winter 2013, Quiz
This quiz is optional, but I strongly encourage you to take it, in one of two ways. The more
serious way is to take the quiz as an out-of-class exam and submit it for grading on Wednesday
Quiz Answers
CS 202, Winter 2013
1. Grading rubric: 16 points are possible. On each part A-H, assign 2 points for a correct
answer, 1 point for PUNT, and 0 points for an incorrect answer. No justication is needed.
A. About asymptotics: f g (f = O(g) N n N
Exam C
CS 202, Winter 2013, Carleton College
This exam contains
this cover (page 1),
six pages of problems (pages 2-7), and
one blank page (after page 7).
You have 150 minutes. No notes, calculator, computer, etc. are allowed.
Feel free to ask claricat
Exam B
CS 202, Winter 2013, Carleton College
This exam contains
this cover (page 1),
four pages of problems (pages 2-5), and
one blank page (after page 5).
You have 60 minutes. No notes, calculator, computer, etc. are allowed.
Feel free to ask claricat
Exam A
CS 202, Winter 2013, Carleton College
This exam contains this cover (page 1), four pages of problems (pages 2-5), and one blank page (page 6).
You have 60 minutes.
No notes, calculator, computer, etc. are allowed.
I will not be available during the
Exam B Answers
CS 202, Winter 2013, Carleton College
Composition note: The solutions here are not self-explanatory, but assume that the reader is looking
at the problem prompts at the same time.
1. The next Hamming code is (15, 11) [as discussed in the ho
Exam A Answers
CS 202, Winter 2013, Carleton College
1. [Make a truth table. The rst, second, third, fth, and seventh rows are true, in my ordering. Each
row corresponds to a clause in the following proposition.] The given proposition is logically equival
Exam 1
CS 202, Fall 2008
Carleton College CS 202, Fall 2008, Exam 1
You have 70 minutes.
You may not use any notes or calculator.
Except on the TRUE/FALSE/PUNT questions, always show your work and explain all of your
answers. Good work often earns partial
Exam 1 Answers
CS 202, Fall 2008
1. One day while walking around the St. Olaf College campus you come to a branch in your
path, where you must turn left or right. One direction leads to Rolvaag Library (where you want
to go) and the other to the High-Volt
Final Exam
CS 202, Fall 2008
Carleton College CS 202, Fall 2008, Final Exam
You have 150 minutes.
You may not use a calculator. You may use a standard-size (8.5 11 ) note sheet with notes
written or typed on both sides by you.
Except on the TRUE/FALSE/PUN
Exam C Solutions
CS 254, Spring 2012
A. Let A, B P. Let M , N be deterministic Turing machines that decide A, B in time
O(nk ), O(n ), respectively. Dene a Turing machine K that, on input w = w1 wn , does the
following.
1. For i = 0, . . . , n:
(a) K runs
Exam C
CS 254, Spring 2013
A. We will reduce EMPTYTM to A. Suppose, for the sake of contradiction, that A is decided
by a Turing machine D. Dene a Turing machine C that, on input M , where M is a Turing
machine:
1. Builds a CFG G, over the same alphabet a
Exam B Solutions
CS 254, Spring 2014
A1. The part of my Python regular expression responsible for matching string literals changes
from [^]* to (?:\|[^])*. That is, the characters within a string literal are either (A)
\ combinations or (B) non- character
Exam D Solutions
CS 254, Fall 2013
A. [Although you are not required to justify answers, I justy mine, for educational value.]
A.A. TRUE. [Using the product construction, you can build a PDA that simulates a PDA
and a DFA at the same time, with nal states