Professional Documents
Culture Documents
Quiz 4
Quiz 4
Quiz 4
− 1 whenever n is a positive
integer. (You can use * to represent multiplication.)
Basis step: 1 * 1!=2! - 1
Recursive step: 1*1! + 2*2! + · · · + k*k! + (k + 1)*(k + 1)! = (k + 1)! − 1 + (k + 1)*(k
+ 1)! = (k + 1)!*(1 + k + 1) − 1 = (k + 2)! − 1
2. (35%) For a full binary tree T, n(T) and h(T) denote the number of vertices and the
height of T, respectively.
Use structural induction to show that n(T) ≥ 2h(T) + 1
Basis step: The root r is a leaf of the full binary tree with exactly one vertex r. This
tree has no internal vertices.
Recursive step: The set of leaves of the tree T = T1 · T2 is the union of the sets of
leaves of T1 and of T2. The internal vertices of T are the root r of T and the union
of the set of internal vertices of T1 and the set of internal vertices of T2.
Symbols you may need: ≤ ≥
Basis step: For the full binary tree consisting of just a root, the result is true
because n(T)=1 and h(T)=0, and 1 ≥ = 2*0 + 1.
Inductive step: Assume that n(T1) ≥ 2h(T1)+1 and n(T2) ≥ 2h(T2)+1 where
n(T1) = 1+n(T1) and h(T)=1+max(h(T1), h(T2)). Therefore n(T) = 2 + n(T1) + n(T2)
≥ 1 + 2h(T1)+1 + 2h(T2)+1 ≥ 1+2
3. (15%) Give a recursive algorithm for finding the sum of the first n positive
integers by filling the blanks below:
4. (30%) Use strong induction to show that every positive integer n can be written
as a sum of distinct powers of two, that is, as a sum of a subset of the integers 2 0
= 1, 21 = 2, 22 = 4, and so on. Let P(n) be the statement “n can be written as a sum
of distinct powers of two”. You can use 2^0 to represent 20; use (k + 1)/2 to
k+1
represent ; use * to represent multiplication
2
[Hint: For the inductive step, separately consider the case where k + 1 is even and
where it is odd. When it is even, note that (k + 1)/2 is an integer.]
Symbols you may need: ≤ ≥ ∈ ∀