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
Expected 4 year cost of
college
Loan amount
60,000
Annual interest rate
0.0376 Monthly interest rate
28,000
0.0031
of monthly
10 Number
payments
Number of years to pay
back loan
Discount rate
120
0.07
Go to college
salary
Age Annual
with degree
18
19
20
2
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
Expected 4 year cost of
college
Loan amount
200,000
160,000
0.12 Monthly interest rate
Annual interest rate
0.0100
of monthly
10 Number
payments
Number of years to pay
back loan
Discount rate
120
0.07
Go to college
salary
Age Annual
with degree
18
19
20
2