ECE608 Homework #7 Solution, Fall 2003
(1) CLR 11.1-1 To nd 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 large
ECE608 Homework #8 Solution, Fall 2003
(1) CLR 12.2-1 Based on the structure of the binary tree, and the procedure of Tree-Search, any node that is examined by the algorithm must either be all subsequent nodes examined, or all subsequent nodes. This occur
ECE 608: Computational
Models and Methods
Office: MSEE 236
email: [email protected]
phone: +1 765-494-0638
Provide fundamental knowledge regarding the
design and analysis of computer algorithms.
Provide tools to analyze a
EE608, Spring 2004, Homework #3 Solution
(1) CLR 4.1-6
T (n) = 2T ( n) + 1.
Change variables to m = lg n n = 2m .
T (2m ) = 2T (2m/2 ) + 1.
Change functions to S(m) = T (2m ).
S(m) = 2S( m ) + 1.
This is solvable by case 1 on the Master Theorem, since a
EE608, Fall 2004, Homework #1 Solution
HW 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. Observ
EE608, Fall 2003, 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| .
ECE608 Homework #4 Solution, Fall 2003
(1) CLR 6.1-6 No, 23, 17, 14, 6, 13, 10, 1, 5, 7, 12 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 th
ECE608 Homework #6 Solution
(1) CLR 8.2-4 For the preprocessing step, compute the C array as in lines 1 through 7 of CountingSort. Then for any query Num-in-Range(a, b), we simply return C[b] C[a 1], where C = 0. The query requires O(1) time to answer.
ECE608 Homework #5 Solution, Spring 2004
(1) CLR 7.1-1 See Figure 1 (a) The initial array and position of i and j indices at the beginning of the rst iteration of the for loop. Because A[j] x, i is incremented by one to p and A[p] is exchanged with itself
EE 608: Computational Models and Methods Lecture 4: Recurrences
Read Chapter 4 and section 28.2 of Introduction to Algorithms
ECE 608, Spring 2004 [ 1 ]
Recurrences A recurrence is an equation or inequality that describes a function in terms of its value(
EE 608: Computational Models and Methods Lecture 14: Graphs, BFS, DFS, Topological Sort, and Strongly Connected Components
Read Chapter 22 of Introduction to Algorithms
Graphs Graph representations of data structures are very useful in a variety of discip