Worst-Case and Average-Case Analysis · Multiple choice · 1 mark
The algorithm below returns the largest element of , .
FindMax(A, n)
m = A[1]
for i = 2 to n
if A[i] > m
m = A[i]
return mWhich statement is a loop invariant that is true at the start of every iteration of the for loop (including the first, with ) and, together with the loop’s exit condition, proves the algorithm correct?
Answer: (A)
Before the iteration with index , holds the maximum of the elements already examined, . It holds at because , each iteration keeps it true, and when the loop ends with it says . The version that includes is false on entry to the iteration ( need not equal ); is not maintained (a later element may be larger); fails whenever is not a new maximum.
Priority Queues and Heaps · Multiple choice · 3 marks
Extract-Max on a max-heap with keys removes , moves to the root, and sifts it down in a heap of keys. At each level the sift-down compares the two children with each other (one comparison, none if there is only one child) and then compares the larger child with the moving key (one comparison); it stops when the moving key is at least as large as both children or has no child. What is the largest possible number of key comparisons this Extract-Max can use?
Answer: (D)
The heap left after the removal has keys, so its height is and the moving key can descend at most four levels. Each level costs at most two comparisons, giving , and this is reached when the moving key is smaller than everything on its path (for instance the minimum moved from the end of a decreasing array). One comparison per level gives but forgets the comparison between siblings; uses the height of a -key heap, and is .
Hashing · Multiple choice · 1 mark
Which statement about quadratic probing, , is correct?
It avoids all clustering, because any two keys examine their slots in different orders.
It suffers primary clustering exactly as linear probing does, since runs of occupied slots keep growing.
It avoids primary clustering, but keys with the same follow the same probe sequence.
It examines every slot for every choice of , and , so insertion succeeds while .
Answer: (C)
(C). Two keys with different starting slots follow different sequences whose gaps grow, so runs of consecutive occupied slots do not trap them (no primary clustering); but two keys with the same get identical sequences (secondary clustering), which contradicts the first option. The last option is false: with , and only the four slots (relative to the start) are ever probed.
Randomized Algorithms and Quicksort · Short answer · 2 marks
The array holds a uniformly random permutation of . A descent is an index with . What is the expected number of descents?
. Let . By symmetry the two values are equally likely to be in either order, so and .
Minimum Spanning Trees and Lower Bounds · Multiple choice · 1 mark
In a connected weighted graph , the edge is the unique heaviest edge on some cycle of . Which statement is true?
belongs to every minimum spanning tree, because it connects its two endpoints directly.
belongs to some minimum spanning tree, provided no other cycle of contains .
is the heaviest edge of .
belongs to no minimum spanning tree of .
Answer: (D)
This is the cycle property. If a spanning tree contained , then removing splits into two parts, and some other edge of crosses between them. Since , the tree is strictly lighter, so is not minimum. Hence is in no MST. It need not be the heaviest edge of (a heavier edge may be a bridge), and the number of other cycles through is irrelevant.
Data Structures and Algorithms · University of Michigan (Michigan, UMich, U of M) · also written EECS281
Make a free, printable EECS 281 practice exam: choose the topics, the length and the difficulty above, and get an exam-style PDF with a full answer key. Each paper draws on 350 original questions and skips the ones you have already seen.
Start with the past exams and tests your instructor or the Michigan library shares: they show what your course actually asks. Most courses only have a few, so once you have worked through them, make fresh EECS 281 practice exams here on the same topics, with full answer keys, as many as you need. The questions here are original, not copies of past exams.
questionbank.dev is independent and not affiliated with University of Michigan. Course codes only say which topics a paper covers; papers are original practice material, not past or upcoming exams.