hw 1 - c + 3 c + + n c a. Show that S(n) is O(n c+1 ) Big O...

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

View Full Document Right Arrow Icon
1a. If c is a positive real number < 1, then each term after the previous will be smaller because a number from 0 < c < 1 to any power greater than 1 will be strictly less than the value itself, so it is big theta(1). 1b. If c is 1, then each term will be 1, so you will have n terms of 1, so it is big theta(n). 1c. If c is > 1, then each subsequent term will increase by c times, and when n gets large enough, the smaller terms can be disregarded since they will be very small when n is very large, so it is big theta(c n ) 2. 2 + 4 + 6 + · · · + 2n = n(n + 1) For S(1), 2 = 1(1+1) = 2 so it is true. If S(1) . .. S(k) are true, then so is S(k+1), so k(k+1) + 2(k+1) <== next term = (k+1)((k+1)+1) k 2 + k + 2k + 2 = (k+1)(k+2) k 2 + 3k + 2= k 2 + 3k + 2 Therefore, 2 + 4 + 6 + · · · + 2n = n(n + 1). 3. ? F 0 = 0; F 1 = 1; F n = F n ? 1 + F n ? 2 : Use induction to prove that F n _ 2 0:5n for n _ 6. For S(6), F 6 >= 2 0.5*6 , where F 6 = 8, so 8 >= 2 3 , 8 >= 8. If S(6) . .. S(k) are true, then so is S(k+1), so F (6+k) >= 2 0.5*k+1 4. S(n) = 1 c + 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c + 3 c + + n c a. Show that S(n) is O(n c+1 ) Big O = upper bound, and n c+1 = n*n c , so you have n n c terms. When you add the previous terms from 1 c to n c , it is strictly less than adding n c terms. b. ? Show that S(n) is (n c+1 ). Big Omega = lower bound 5a. using n = 2 k a 1 = 1, a k+1 = 2a k , so 1, 2, 4, 8, 16, . .. What is the smallest k for which a k n? N/A 5b. using n = 2 k a 1 = 2, a k+1 = a k 2 What is the smallest k for which a k n? a k = 2, 4, 16, 196, . .. 1 6a. False 6b. False 6c. False 7a. So you have j levels with d children at most per node, which means d j maximum nodes. 7b. Depth k = largest level, which means k d maximum nodes at that level, so k d + (k-1) d + . .. + 1 d . So O(k d ). 7c. n nodes and d children. So minimum depth = floor(log d (n)) - 1 depth, so O(log d (n)). 8a. n-1, n-2. O(log n). O(n log n). Yes 8b. max 2 n-1, 2 n-2, but it really depends. O(2 n ). O(n*2 n ), which is O(2 n ). No...
View Full Document

This note was uploaded on 01/09/2012 for the course CSE 101 taught by Professor Staff during the Spring '08 term at UCSD.

Page1 / 2

hw 1 - c + 3 c + + n c a. Show that S(n) is O(n c+1 ) Big O...

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

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