You are on page 1of 2

Solutions to Homework One CSE 101

1. (a) By the usual formula for a geometric series, for c = 1,


S(n) =
c
n+1
1
c 1
.
(b) When c < 1, the formula above can more conveniently be written as
S(n) =
1 c
n+1
1 c
,
from which we see that S(n) lies between 1 and 1/(1c) and is hence (1). For c = 1, S(n) = n+1,
which is (n). For c > 1, by the formula, S(n) lies between c
n
and
c
c1
c
n
and is thus (c
n
).
2. Let S(n) denote the statement 1 + 3 + + (2n 1) = n
2
. Well show by induction that S(n) is true
for all positive integers n.
Base case: n = 1. This is immediate.
Inductive step. Suppose S(1), . . . , S(k) are true. Well show that S(k +1) is also true. This is because
1 + 3 + + (2k + 1) = (1 + 3 + + (2k 1)) + (2k + 1) = k
2
+ (2k + 1)
where the last equation uses the inductive hypothesis to simplify 1 + 3 + + (2k 1). We nish by
simplifying k
2
+ (2k + 1) = (k + 1)
2
.
3. Problem 0.3(a). In this problem it is important to have two base cases.
Base cases: n = 6 and n = 7. These can be checked individually.
Inductive step. Suppose the statement holds upto some value of n greater than 6; we need to extend
it to n + 1. This follows because
F
n+1
= F
n
+ F
n1
2
0.5n
+ 2
0.5(n1)
(induction hypothesis)
2 2
0.5(n1)
= 2
0.5(n+1)
.
4. Dene S(n) = 1
c
+ + n
c
.
(a) Each term in the series is at most n
c
. Therefore, S(n) n
c
+ + n
c
= n n
c
= n
c+1
.
(b) Each term in the 2nd half of the series is at least (n/2)
c
, so S(n) (n/2) (n/2)
c
= n
c+1
/2
c+1
.
5. (a) We have a
k
= 2
k1
. The rst time this exceeds n is when k is roughly log n.
(b) We have a
k
= 2
(2
k1
)
. This rst exceeds n is when 2
k1
exceeds log n, that is, when k is roughly
log log n.
6. (a) True. log
2
n = (log
2
3)(log
3
n), which is O(log
3
n).
(b) False. 2
log
2
n
= n whereas 2
log
3
n
= 2
(log
3
2)(log
2
n)
= (2
log
2
n
)
log
3
2
= n
log
3
2
, which is much smaller
than n.
(c) True. (log
2
n)
2
= ((log
2
3)(log
3
n))
2
= (log
2
3)
2
(log
3
n)
2
.
7. (a) 100n
3
+ 3
n
= O(3
n
).
(b) 200nlog(200n) = O(nlog n).
(c) 100n
2
2
n
+ 3
n
= O(3
n
).
1
(d) 100nlog n + 20n
3
+

n = O(n
3
).
8. d-ary tree. Here d 2.
(a) The maximum number of nodes at level j is d
j
.
(b) The maximum number of nodes in a tree of depth k is at most 1 + d + + d
k
d
k+1
.
(c) If the tree has n nodes, its depth k must satisfy n d
k+1
, and thus k is (log
d
n).
2

You might also like