ECE608 Homework #5 Solution
(1) CLR 6.1-6
No, h23, 17, 14, 6, 13, 10, 1, 5, 7, 12i is not a heap because the heap property does not
hold between the 4th element and its second child, the 9th element (i.e., 6 < 7).
(2) CLR 6.1-7
Let i represent the index o
Spring 2016
ECE608, Homework #10 Solution
(1) CLR 22.1-6
We are looking for a universal sink i.e., a vertex with in degree of |V | 1 and out
degree of zero. In the adjacency matrix the elements in row i represent the edges that
our out-going from node i t
ECE608, Homework #2 Solution
(1) CLR 3.1-2
To show that (n + a)b = (nb ), we want to find constants c1 , c2 , and n0 > 0 such
that 0 c1 nb (n + a)b c2 nb for all n n0 . Note that n + a n + |a| 2n, when
n
n
n
|a| n, and n + a n |a| , when |a| . Thus, 0 n +
ECE608, Homework #11 Solution
(1) CLR 22.3-7
DFS-STACK(G)
1. for each vertex u V [G]
2.
do color[u] WHITE
3.
[u] NIL
4. time 0
5. for each vertex u V [G]
6.
do if color[u] = WHITE
7.
then DFS-VISIT-STACK(u)
DFS-VISIT-STACK(u)
1. PUSH(S, u)
2. while !empty
ECE608 Homework #7 Solution
(1) CLR 11.1-1
To find the maximum element of the set S, it requires searching the entire table T
in the worst case. Note that NIL is returned if there are no elements in the table T ;
otherwise, the index to the largest elemen
EE608, Homework #1 Solution
(1) CLR 1.2-2
INSERTION-SORT beats MERGE-SORT when 8n2 < 64n lg n, n < 8 lg n,
n
< lg n, 2n/8 < n, which is true when 2 n 43.
8
(You can solve for n by trial and error using a calculator. Observe that 5 8 < n <
6 8 = 48, since