ECE-665 Computer Algorithms
Homework Assignment 1 Solution
Question R-1.15.
Proof:
f (n) is O(g(n) constant c0 and n0 , so that f (n) c0 g(n) for any n when n n0 .
Similarly,
d(n) is O(h(n), constant c1 and n1 , so that d(n) c1 h(n) for any n when n n1 .
ECE-665 Computer Algorithms
Homework Assignment 2 Solution
Question C-3.2.
Answer:
An O(h + s) algorithm is shown in Figure. 1. The algorithm rst perform a binary search to nd an
element whose key is equal to k and the current index (e.g., P os). Then, it
ECE-665 Computer Algorithms
Homework Assignment 3 Solution
Question R-5.9.
Answer:
Matrix multiplication is an associative but not a commutative operation. This means that we are free to
parenthesize the multiplication however we like, but we are not free
ECE-665 Computer Algorithms
Homework Assignment 4 Solution
Question R-6.2.
Answer:
Since G is a simple connected graph, we know that n 1 <= m <= n(n 1)/2. From it, we can
show log(n 1) <= log(m) <= log(n) + log(n 1) log(2) < 2 log(n). It means log(n) <= l
ECE-665 Computer Algorithms
Homework Assignment 5 Solution
Question C-7.2.
Answer:
The example is shown in Figure. 1. The shortest path from A to E computed by Dijkstras algorithm is
A D E, whose length is 7. Actually, the shortest path from A to D is A B