Professional Documents
Culture Documents
PK
www.vustuff.com
CS502 Fundamentals of Algorithms
Final Term Examination - February 2005
Time Allowed: 150 Minutes
Instructions
Please read the following instructions carefully before attempting any of the
questions:
(a) Kruskals algorithm for minimum weight spanning trees is an example of dynamic
programming algorithm.
(b) An arbitrary graph with G (V, E), with |E| = |V|-1 edges is a tree.
(c) If problem A reduces (is polynomial-time reducible) to problem B and B is NP-
complete then A is NP-complete.
1 True
2 False
3 Unknown
1 O( n)
3
2 O( n )
2
3 O( n log n)
2
4 O( n )
Given a list of N integers, the 3-sum problem is to determine whether there exists 3 integers
in the list (not necessarily distinct) such that x + y + z = 0. Suppose that you are executing the
brute force algorithm below on a computer that executes 1 billion operations (addition,
increment, or comparison) per second.
(a) Estimate how many seconds it will take (in the worst case) to solve a problem of size N =
1,000? Full credit if you are within 1% of the exact answer.
(b) Of size N = 10,000?
1 O(logn)
2 O(n)
3 O(nlogn)
2
4 O(n )
5 O(2n)
Where (i-j, w) means that the edge that connects node i to node j has weight w. give the
parent-link representation of the shortest-paths tree from node 0 that is computed by
Dijkstra's algorithm for the graph using the standard adjacency-lists representation.
Kruskals algorithm (choose best non-cycle edge) is better than Prim's (choose best tree
edge) when the graph has relatively few edges.
1 True
2 False
3 Unknown