Midterm.sp10

Midterm.sp10 - Signature _ Login Name _ Name _ Student ID _...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
0 Signature ___________________ Name ______________________ Login Name _________________ Student ID __________________ Midterm CSE 21 Spring 2010 Page 1 ___________ (30 points) Page 2 ___________ (17 points) Page 3 ___________ (13 points) Page 4 ___________ (24 points) Page 5 ___________ (7 points) Page 6 ___________ (7 points) Total ___________ (98 points) (93 points = 100%)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1 { 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 ). ___________________________ if n ________ S ( 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? f ( 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 2 nd part of RR = ___________________________, by IHOP = ___________________________ = ___________________________ So, by induction, S ( n ) = ____________ for all n >= 1 (as ______________). A) 4n – 2n B) n 3 – n C) n 4 – n 2 + 2 D) n 2 + n E) 2n + n F) 2 n + n
Background image of page 2
2 { What are the four general decompositions of recursive algorithms discussed in class? _______________________________ _______________________________ _______________________________ _______________________________ Every year, Alice's car depreciates (loses its value) by 5% of its value, but she also pimps out her ride each year which increases its value by $550. The car was worth $20,000 when she got it (year 0). Give a recurrence relation for S ( n ), the value of Alice's car after
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Midterm.sp10 - Signature _ Login Name _ Name _ Student ID _...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online