# 2002 S

*215,629*pages on

this wiki

## Ad blocker interference detected!

### Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

1. (10%) Let A [1..n] be an array storing all the student identification numbers of all current students is Tsing Hua University. Give an O(n) time algorithm to sort the element of A.

2. (10%) The Fibonacci numbers are defined by the following recurrence:

- = 0,
- = 1,
- = + , for i≧2,
- Derive an explicit expression for .

3. (15%) In the longest-common-subsequence problem, we are given two sequences A=[] and B=[], and wish to find a maximum-length common subsequence X of A and B.(Please clearly define your notation.)

- (1) (5%) Describe a dynamic-programming algorithm to find the maximum-length common subsequence X of A and B.(Please clearly define your notation.)
- (2) (5%) analyze the running time and space requirements of your algorithms (in terms of big-O notation).
- (3) (5%) If we only want to find the length of X, what is the space requirement? Why?

4. (10%)

- (a) (5%) Describe the Floyd-Warshall algorithm to compute the weights of the all-pairs shortest paths on a directed graph G=(V, E), What is the time complexity of this algorithm? Why?
- (b) (5%) Give an algorithm to determine the all-pairs shortest paths via constructing the predecessor matrix Π from the intermediate results in (a). What is the complexity of this algorithm? Why?

5. (10%) Let G(V,E) be an undirected, connected graph with weight function w : E→R, and suppose that |E|≧|V|. Given an efficient algorithm to compute the second-best minimum spanning tree of G.

6. (10%)

- (a) (5%) Describe the Strassen’s algorithms for matrix multiplication.
- (b) (5%) Derive the time complexity of applying this algorithm to multiply two n×n matrices.

7. (5%) Explain why the following statement is wrong and provide your own correct version. ”NP” stands for the set of problems that cannot be solved in polynomial time in its worst case, therefore P∩NP=Ø.”

8. (15%) The Fast Fourier Transform(FFT) problem is to calculate the following:

Where i=, and are given numbers. We also know that

- if a is even
- if a is odd

Describe an algorithm that solves the FFT problem using the divide-and-conquer strategy. Also explain why its time complexity is O(n log n)

9. (15%) The following is the definition of the Bin Packing problem. Bin Packing: There are n items with sizes , where 0≦Si≧1. We want to pack the items in bins where each bin has a capacity of 1. The Bin Packing problem is to determine the minimum number of bins necessary to pack all items. We also know that the Partition problem (described below) is NP-complete. Prove that the Bin Packing Problem is NP-hard by transforming to or from the Partition problem. The Partition Problem is : Partition: Let a finite set A be given, where each has size s(a) in positive integers. Is there a subset such that the subset A’ contains exactly half of the total size, i.e,