Worst-Case and Average-Case Analysis · Multiple choice · 1 mark
Algorithm takes exactly steps on inputs of size and algorithm takes exactly steps. Among the powers of two , what is the smallest for which is strictly faster than ?
Answer: (D)
is faster when , i.e. when , i.e. . For : is false; for : is true, and the inequality stays true for larger . So the answer is . The value comes from treating as a constant 1, and from stopping one step too late.
Randomized Algorithms and Quicksort · Multiple choice · 1 mark
An array holds numbers, exactly of which are “good”. An algorithm repeats the following until it stops: choose an index uniformly at random (independently each time, with replacement) and read that entry, which costs steps; stop as soon as the entry read is good. What is the expected total number of steps?
Answer: (D)
(D). Each read is good with probability , so the number of reads is geometric with mean , and the expected cost is steps. The value counts reads rather than steps, is the cost of a single read, and counts only the expected failed reads.
Priority Queues and Heaps · Short answer · 2 marks
The array is a max-heap with . Extract-Max returns , moves to the root and sifts it down, always swapping with the larger child. Write the array that remains.
The value is returned and becomes the root of the nine-key heap . The children : swap with (index ). The children of index are : swap with (index ). Index has no children (). The array is .
Hashing · Short answer · 2 marks
A table has slots and uses double hashing with , and . The keys , , are inserted, in this order, into the empty table. Write the final table (put in an empty slot).
| slot | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
| key |
Answer: –; 15; –; –; 22; 8; –
: , slot is empty. : (occupied), , next probe . : (occupied), , next probe . The table has in slot , in slot , in slot .
Minimum Spanning Trees and Lower Bounds · Short answer · 2 marks
The complete graph has vertices , and the edge has weight . What is the weight of a minimum spanning tree of this graph? Give the number and a one- or two-sentence reason.
The weight is . Root any spanning tree at vertex : each vertex has a parent edge of weight , so the tree weighs at least . The star centred at vertex has exactly these edges, so it attains the bound.
Data Structures and Algorithms · University of Toronto (UofT, U of T, UToronto) · also written MIE245, MIE 245
Make a free, printable MIE245H1 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 UofT library shares: they show what your course actually asks. Most courses only have a few, so once you have worked through them, make fresh MIE245H1 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 Toronto. Course codes only say which topics a paper covers; papers are original practice material, not past or upcoming exams.