Docsity

Midterm Exam for Algorithm Analysis and Design - Fall 2005 | CPSC 5115G, Exams of Computer Science

Toggle sidebar
bg1
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.

Partial preview of the text

Download Midterm Exam for Algorithm Analysis and Design - Fall 2005 | CPSC 5115G and more Exams Computer Science in PDF only on Docsity!

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ļ‚·N^2 + 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 ļƒž C C1 ļƒž C3 C3 ļƒž C C2 ļƒž C4 C4 ļƒž C6 C5 ļƒž C 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.