# A Counter Example For This Algorithm

718 Words3 Pages
Ricardo Rigodon and Maulik Patel
Homework 1
Due 9/15

1-6 A counter example for this algorithm can be shown as follows.
U = {27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43}
S1 = {27, 28}
S2 = {29, 30, 31, 32}
S3 = {33, 34, 35, 36, 37, 38, 39, 40, 41}
S4 = {27, 28, 29, 30, 31, 32, 33, 34}
S5 = {35, 36, 37, 38, 39, 40, 41, 42, 43}
The correct answer for this is S4 and S5. However, the algorithm will choose S3, S2, and then S1 which is incorrect. S3 because it has the most uncovered, followed by S2, and then S1.

1-16 Prove n3 + 2n is divisible by 3 BASE CASE : n = 0 Inductive hypothesis : k3 + 2n = 3m = P(k) Inductive Step : P(k+1)= (k+1)3 + 2(k+1) = k3 + 3k2 + 3k + 1 + 2k + 2 = k3 + 2k + 3k2 + 3k + 3 = 3m + 3k2 + 3k + 3 (k3 + 2n = 3m from Inductive Hypothesis) = 3(m + k2 + k + 1)

1-25 (a) Takes about 100 seconds. If proportional to n2 (102 = 100). (b) n2 is a less efficient algorithm than n log n should take 100 µs as we know logarithms will divide the input in half until complete.

2-8 (a) f(n) = log n2; g(n) = log n + 5 f(n) = θ (log n +5) since log n + 5 multiplied by C = 2 is an upper bound of f(n) and multiplied by C= 1/3 is a lower bound of f(n) (b) f(n) = (n)1/2 g(n) = log n2 f(n) = Ω (log n2) since n1/2 grows faster than log n2 (c) f(n) = log2 n; g(n) = log n f(n) = Ω (log