
CPSC 5115 Algorithm Analysis And Design
MidāTerm Exam Fall 2005
This exam must be handed in before 6:00 PM on Wednesday, October 12.
Distance learners: Submit as an attachment to eāmail.
This exam is openābook, openānotes, and not proctored. Do your own work.
1. (20 points) Find the time complexity of the following functions, with T(1) = 4 for each.
a) T(N) = 2ļ·T(N/4) + 7ļ·N
b) T(N) = 8ļ·T(N/2) + 3ļ·N2 + 5ļ·N + 6
c) T(N) = 9ļ·T(N/3)
2. (20 points) A graph on five vertices, with V(G) = {1, 2, 3, 4, 5}, can be described by
the following adjacency lists.
N(1) = {3, 4, 5} N(3) = {1, 2}
N(2) = {3, 4, 5} N(4) = {1, 2}
N(5) = {1, 2}
a) How many edges does this graph have?
b) Perform a depthāfirst search on this graph, beginning at vertex 1.
Show both the mark array and back array.
3. (20 points) The following is a list of course prerequisites. In this we use C1 ļ C2 to
denote that course C1 is a prerequisite for course C2.
C1 ļ C2 C3 ļ C4
C1 ļ C3 C3 ļ C5
C2 ļ C4 C4 ļ C6 C5 ļ C6
a) Produce a directed graph that represents this prerequisite list.
Draw the graph neatly and give its adjacency matrix.
b) Do a topological sort (show how you do this) and produce two different sequences
in which the courses can be taken without violating the prerequisites.
4. (20 points) Use the method of Gaussian elimination to solve the following set of
simultaneous equations. Show enough of what you do to convince me that you are
using Gaussian elimination and not some other method.
X + 2Y + 3Z = 1
X + 3Y + 5Z = 2
2X + 4Y + 7Z = 2
5. (20 points) Use the Merge Sort to sort the following list of singleādigit integers.
(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 4). Be sure to show that you are using merge sort.