Vous êtes sur la page 1sur 2

Signature ______________________

Student ID _____________________

Quiz 1
CSE 21
Fall 2010

Name_________________________

Calculate the first 6 terms for the sum of the first n even natural numbers (n = 1, n = 2, n = 3, ... , n = 6). Then to
the right calculate the sequence of differences between these terms. (The first even natural number is 2.)
n
Sequences of differences
1 _______________________ = _____
_____
2 _______________________ = _____
_____
_____
3 _______________________ = _____
_____
_____
4 _______________________ = _____
_____
_____
5 _______________________ = _____
_____
_____
6 _______________________ = _____
Write the recurrence relation for the sum of the first n even natural numbers S(n).

S(n) =

___________________________

if n ________

___________________________

if n ________

Based on the sequence of differences (above) what is a good guess for the closed-form solution to the
recurrence relation above?
A) 4n 2n
B) n3 n
C) n4 n2 + 2
2
f(n) = ____________
E) 2n + n
F) 2n + n
D) n + n
Why?:

Verify this with a proof by induction. Prove S(n) = f(n) for all n ___________ .
Proof (Induction on n):
_________________: If n = ____, the recurrence relation says S(__) = ____,
and the closed-form solution says f(__) = ______ = ____, so S(__) = f(__).
_________________: Suppose as inductive hypothesis that S(k-1) = ____________________ for some k > ___.
_________________: Using the recurrence relation, S(k) = ___________________________, by 2nd part of RR
= ___________________________, by IHOP
= ___________________________
= ___________________________
So, by induction, S(n) = ____________ for all n >= 1 (as ______________).

Let S(n) = 12 + 22 + + n2 be the sum of the first n perfect squares. Find a recurrence relation for S(n).

S(n) =

___________________________

if n ________

___________________________

if n ________

What are the four general decompositions of recursive algorithms discussed in class?
_______________________________

_______________________________

_______________________________

_______________________________

Suppose that today (year 0) your car is worth $21,000. Each year your car loses 10% of its value, but at the end
of each year you pimp out your car a little which increases its value by $175. Write a recurrence relation to
model this situation.

S(n) =

___________________________

if n ________

___________________________

if n ________

Match the statements below with the letters to the right.


_____ Nobel Prize of Computing
_____ "Can machines think?"
_____ "Will a program complete?"

A) Turing Machine
B) Turing Award
C) Halting Problem
D) Turing Test

_____ A theoretical device representing a computing machine to understand limits of computation.

Vous aimerez peut-être aussi