{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

midterm_702_07_sol

# midterm_702_07_sol - Solutions for CAS 702 Midterm 2007...

This preview shows pages 1–2. Sign up to view the full content.

Solutions for CAS 702 Midterm 2007 Problem 1a Let k j and i j be the values of k and i respectively after statement i := i + i is executed j times. Then we observe that i 0 = 2 , k 0 = 1 and i j = 2 j +1 , k j = i 2 j - 1 = 2 2 j . The loop ends when k j = 2 2 j n , or j lg n 2 . So j = lg n 2 = Θ(lg n ). Problem 1b The conjecture is false. A counter example is f ( n ) = 2 n and g ( n ) = n . Problem 1c Both are false. The curve f ( n ) keeps fluctuating and touching the curves of a Θ( n 2 ) and a Θ(1) function. Problem 1d We have 1 + α = α 2 since α is a root of x 2 - x - 1 = 0. We show that α i - 2 F i α i - 1 for i 2 by induction. It hold for i = 2 (base case). Assume the inequalities hold for any k smaller than i . Then, F i = F i - 1 + F i - 2 α i - 2 + α i - 3 = α i - 3 ( α + 1) = α i - 3 α 2 = α i - 1 . Similarly we can prove that α i - 2 F i . It follows immediately that F i = Θ( α i ). Problem 2a The best and worst running time of Heap sort are both Θ( n lg n ) (refer to Exercise 6.4-5). The best running time of Quick sort is n lg n (balanced partitioning),

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern