Homework 7
Date: December 8, 1998
This homework (based on Chapters 7, 8 and 9) is not graded.
Please do the problems to your own satisfaction.
If you have any questions, feel please
to contact Ken or Chee.
We will post solutions next week. We strongly
suggest that you try to solve the problems without looking
at the answers first.
The questions for Chapter 9 has two proofs (induction and
contradiction proofs). YOU NEED TO UNDERSTAND HOW
TO WRITE SUCH PROOFS FOR THE FINAL EXAM.
CHAPTER 7 (DICTIONARIES)
- R-7.2. (page 294)
- R-7.6.
- R-7.9. (page 295)
- R-7.11.
- R-7.12.
- C-7.2 (page 295).
HINT: Assume that S and T contain distinct and
disjoint sets of keys. For any key x (x does not
even have to be in S or T), define S-rank(x)
to be the number of elements in S less than or equal to x.
Similarly define T-rank(x).
To find the k-th smallest element, you
need to find the element x
in S or T such that S-rank(x) + T-rank(x) = k.
You should use some kind of nested binary search.
- C-7.5. (page 296)
- C-7.10. HINT: suppose each node stores a new value called
"size" which is equal to the number of nodes in the subtree
at that node. Modify AVL inserts and deletes
to maintain this information. How does this help our
problem of counting number of keys in the range from k1
from k2
CHAPTER 8 (SORTING)
- R-8.3 (assume that merging two lists of size n takes O(n) time)
- R-8.5
- C-8.16
CHAPTER 9 (GRAPHS)
- Show that the space usage of the adjacency list repreentation
of graphs has complexity big-Theta of m+n.
- R-9.3. (page 389)
- R-9.5.
- Prove by contradiction: if (u,v) is a back-edge in the DFS traversal
of an undirected graph G, then v is an ancestor of u.
HINT: if the "exploration" of a node is not yet complete,
then it remains on path from the current node to the
root of the tree. This path is precisely the sequence
of nodes on the recursion stack.
- Let G be an undirected graph where each node u has an even
degree. Prove by induction on the number m
(of edges) that G has an Euler Tour (this is a path
that goes through each edge of G examply once).