Docsity

Data Structures and Algorithms Practice Exam, Exams of Algorithms and Programming

Toggle sidebar
bg1
Data Structures and Algorithms Practice Exam
Introduction
The Data Structures and Algorithms portion of the Masters Comprehensive Exam (MCE) represents
approximately 1/3 of the exam. The DS&A portion emphasizes basic knowledge and reasoning over
in-depth problem analysis, since it has over 30 questions, and the entire comprehensive exam lasts
for three hours.
Taking the exam
Since the MCE lasts for three hours, this leaves about one hour to complete the DS&A portion,
which in turn leaves about two minutes to answer each problem. There is NO penalty for guessing,
so make sure to answer each one. It is therefore recommended to take this practice test in a hour
sitting, and without referring to the answers until the exam has been completed.
Grading of the exam
Exam grades are determined by the CECS Graduate Committee. Please see the CECS Graduate
Advisor for more information.
Questions
1. Which of the following expressions surely supports the statement f(n) = Ω(g(n))?
a) f(n)≤4g(n) for all n≥1
b) f(n)≥4g(n) for all n≥136
c) lim
n→∞
f(n)
g(n)= 0
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Data Structures and Algorithms Practice Exam and more Exams Algorithms and Programming in PDF only on Docsity!

Data Structures and Algorithms Practice Exam

Introduction

The Data Structures and Algorithms portion of the Masters Comprehensive Exam (MCE) represents approximately 1/3 of the exam. The DS&A portion emphasizes basic knowledge and reasoning over in-depth problem analysis, since it has over 30 questions, and the entire comprehensive exam lasts for three hours.

Taking the exam

Since the MCE lasts for three hours, this leaves about one hour to complete the DS&A portion, which in turn leaves about two minutes to answer each problem. There is NO penalty for guessing, so make sure to answer each one. It is therefore recommended to take this practice test in a hour sitting, and without referring to the answers until the exam has been completed.

Grading of the exam

Exam grades are determined by the CECS Graduate Committee. Please see the CECS Graduate Advisor for more information.

Questions

  1. Which of the following expressions surely supports the statement f (n) = Ω(g(n))? a) f (n) ≤ 4 g(n) for all n ≥ 1 b) f (n) ≥ 4 g(n) for all n ≥ 136 c) (^) nlim→∞^ f g^ ((nn)) = 0

1

d) none of the above

  1. Let k denote the degree of polynomial p(n), and l the degree of polynomial q(n). If p(n) = o(q(n)), then necessarily a) k = l. b) k < l. c) k > l. d) none of the above
  2. If f (n) = O(g(n)) and f (n) = Ω(g(n)), then it is always true that

a) f (n) = o(g(n)). b) f (n) = Θ(g(n)). c) f (n) = ω(g(n)). d) both a) and b) are always true.

  1. Which of the following expressions best describes the growth of the sum 1+1/2+1/3+· · ·+1/n?

a) Θ(1/n) b) Θ(1) c) Θ(log n) d) Θ(n log n)

  1. Given positive functions f (n) and g(n), if we know that lim n→∞(log f (n) − log g(n)) = 1, then we also know that a) f (n) = o(g(n)). b) f (n) = Θ(g(n)). c) f (n) = ω(g(n)). d) more information is needed about f and g to reach a definite conclusion.
  2. An algorithm takes as input an n × n Boolean matrix A. If the running time of the algorithm is T (n) = O(n log n) when n is used as the input size parameter, then which of the following expressions describes the big-O growth of T (m), the running time of the algorithm when m = n^2 is used as the size parameter? a) O(√m log m) b) O(m^2 log m) c) O(m log m) d) O(m^2 log^2 m)
  3. Which of the following is not a desirable property of a hash function h(x)?
  1. Which of the following graph problems cannot be solved in time that is linear with respect to the sum of the number of vertices and edges in the graph (i.e. O(m + n)). a) determining if a simple graph is connected b) determining if a simple graph is bipartite c) determining a minimum spanning tree for a connected weighted graph d) determining a topological sort of the vertices for a directed acyclic graph
  2. Suppose directed graph G is weakly but not strongly connected, and path P = a, b, c, d provides a weak (but not strong) connection from a to d within G. Then we surely know that a) either (a, b), or (b, c), or (c, d) is an edge of G. b) (a, b), and (b, c), and (c, d) are edges of G. c) either (b, a), or (c, b), or (d, c) is an edge of G. d) (b, a), and (c, b), and (d, c) are edges of G.
  3. Let G = (V, E) be the undirected graph whose edges are {(a, b), (b, c), (c, d), (a, d)}. If T is the depth-first spanning tree of G rooted at vertex a, it follows that T has branch(es). a) 1 b) 2 c) 3 d) 4
  4. The worst case running time T (n) for inserting n elements into an initially-empty binary search tree is a) T (n) = O(n^2 ). b) T (n) = O(√n log n). c) T (n) = O(n). d) T (n) = O(n log n).
  5. Binary search tree T is said to be balanced when, for every node n in T ,

a) n’s left and right subtrees have equal height. b) n’s left and right subtrees have equal size. c) n’s left and right subtrees have heights that differ by at most one. d) n’s left and right subtrees have sizes that differ by at most one.

  1. If numbers from the set { 1 ,... , n} are selected at random (without replacement) and inserted into an initially-empty binary search tree, then the big-O expression that best describes the average (taken over all possible resulting trees) height of the resulting tree is a) O(n).

b) O(log n). c) O(√n). d) O(n).

  1. Which of the following sorting tasks would not be appropriate for Counting Sort?

a) sorting millions of products by their 15-digit serial numbers b) sorting millions of employees by their ages c) sorting each day of the calendar year by the high temperature (in Celsius rounded to the nearest integer degree) recorded in the city of Long Beach on that given day d) sorting each vehicle registered in the state of California by the year it was manufactured

  1. Which of the following best describes the worset-case running time of Insertion Sort when sorting n 32-bit unsigned integers? a) T (n) = Θ(√n) b) T (n) = Θ(n) c) T (n) = Θ(n log n) d) T (n) = Θ(n^2 )
  2. Quicksort is guaranteed to run in time O(n log n) so long as the pivot is

a) randomly selected. b) set to the median of the first, middle, and last array element. c) set to the median of the array. d) none of the above

  1. When following Kruskal’s algorithm, the greedy choice is to

a) remove the edge of greatest cost from the graph so long as its removal does not disconnect the graph. b) add the edge of least cost to the forest so long as its addition does not create a cycle. c) add the vertex having least connection cost to the current tree. d) remove the vertex having greatest connection cost from the tree.

  1. When following Huffman’s algorithm, the greedy choice is to

a) select the two probabilities of least value for merging. b) select the two probabilities of greatest value for merging. c) add the codeword of shortest length to the code being constructed. d) remove the codeword of greatest length from the code being constructed.

  1. Which of the following greedy algorithms has an implementation that most resembles that of Dijkstra’s algorithm?
  1. The Floyd-Warshall dynamic-programming algorithm defines the matrix of numbers dkij , where i and j are graph vertices satisfying 1 ≤ i, j ≤ n, and k ∈ { 0 , 1 ,... , n}. Moreover, dkij represents a) the distance from i to j when restricted to paths that traverse at most k edges. b) the distance from i to j when restricted to paths that traverse at least k edges. c) the distance from i to j when restricted to paths whose intermediate vertices must lie within the set { 1 ,... , k}. d) the distance from i to j when restricted to paths whose intermediate vertices must lie within the set {k + 1,... , n}.
  2. The problem of determining if a bipartite graph has a perfect matching is most naturally reduced to the problem of a) finding a Hamilton cycle in a simple graph. b) finding a vertex cover in a simple graph. c) finding the maximum flow in a directed network. d) finding the longest path in a directed network.
  3. The problem of determining the maximum flow in a directed network is most naturally reduced to the problem of a) determining if a 0-1 Knapsack has a profit that exceeds some threshold. b) finding the longest path in a directed network. c) determining if there is a path from one vertex to another in a graph. d) finding the longest path in an acyclic directed network.
  4. Professor Jones has just proved that there is no polynomial-time algorithm for solving the 0- Knapsack optimization problem. Because of this we also know there is no polynomial-time algorithm for solving each of the following problems, except for a) determining if a Boolean formula has a satisfying assignment. b) determining if a graph has a Hamilton cycle. c) determining if a set of integers has a subset that sums to some value t. d) determining the longest path in a directed acyclic graph.
  5. The Subset Sum decision problem is most closely associated with

a) the Set Partition decision problem. b) the 3SAT decision problem. c) the Hamilton Cycle decision problem. d) the Vertex Cover decision problem.

Exam Solutions for Data Structures and Algorithms

  1. b
  2. b
  3. b
  4. c
  5. b
  6. a
  7. b
  8. a
  9. d
  10. d
  11. b
  12. c
  13. c
  14. c
  15. a
  16. a
  17. c
  18. b
  19. a
  20. d
  21. c
  22. b
  23. a
  24. b
  25. c
  26. d
  27. c