CS 173: Discrete Structures, Fall 2010
Homework 8
This homework contains 3 problems worth a total of 38 regular points.
It is due on Friday,
October 29 at 4pm. Put your homework in the appropriate dropbox in the Siebel basement.
1.
More on recurrences [12 points]
(a) (6 points) Derive closed form solutions for the following two recurrences.
i.
T
(0) = 2 and
T
(
n
) = (
n
+ 1)
T
(
n

1)
.
ii.
T
(0) = 1 and
T
(
n
) =
T
(
n

1) + 3(
n

1)
2
+ 3(
n

1) + 1
.
(b) (6 points) Give a closed form of the following recurrence using a recursion tree.
Assume
n
is a power of 2.
i.
T
(1) = 1 and
T
(
n
) = 4
T
(
n/
2) +
n
3
2.
Algorithm analysis [10 points]
Consider the following code. Its output is a new array
b
1
,b
2
,...,b
k
. (Don’t worry about
the details of how this new array is created.)
1. Proc funct(
a
1
,a
2
,...a
n
: array of real numbers)
2.
k
= 1
3.
b
k
=
a
1
4. for
i
= 2 to
n
5.
c
= 0
6. for
j
= 1 to
i

1
7.
c
=
a
j
+
c
8. if (
a
i
≥
c
)
9.
k
=
k
+ 1
10.
b
k
=
a
i
11. return
b
1
,b
2
,...,b
k
(a) (2 points) Give a brief English description of what the function funct computes.
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.
 Spring '08
 [email protected]
 Big O notation, Analysis of algorithms, Siebel

Click to edit the document details