Greedy choice property, interval scheduling, Huffman coding, merge sort, the master theorem, closest pair and Strassen.
39 cards · basic cards · AI-written, checked twice. Edit anything.
- What is the greedy choice property?
Show answer
A property where making the locally optimal choice at each step leads to a globally optimal solution.
- When does a greedy algorithm guarantee an optimal solution?
Show answer
When the problem exhibits both the greedy choice property and optimal substructure.
- In interval scheduling, what greedy criterion selects the optimal set of non-overlapping intervals?
Show answer
Always select the interval that finishes earliest.
- What is an exchange argument in algorithm analysis?
Show answer
A proof technique showing that any optimal solution can be transformed into a greedy solution without losing optimality.
- What does Huffman coding produce?
Show answer
A prefix-free binary encoding where more frequent characters use shorter codewords.
- What are the steps to build a Huffman tree?
Show answer
Repeatedly combine the two nodes with smallest frequencies into a new node until one tree remains.
- Why are Huffman codes called prefix-free?
Show answer
No codeword is a prefix of any other codeword, enabling unique decoding.
- Why is Huffman coding optimal among all prefix-free codes?
Show answer
It minimizes the expected codeword length because it places less frequent characters deeper in the tree.
- What is the divide phase of merge sort?
Show answer
Recursively split the array in half until each subarray has one element.
- What is the conquer and merge phase of merge sort?
Show answer
Merge adjacent sorted subarrays by comparing elements and placing the smaller one first.
- What is the time complexity of merge sort?
Show answer
O(n log n) in all cases: best, average, and worst.
- What is the space complexity of merge sort?
Show answer
O(n) because merging requires auxiliary arrays.
- Is merge sort a stable sorting algorithm?
Show answer
Yes, equal elements maintain their original relative order.
- State the Master Theorem for recurrences of the form T(n) = aT(n/b) + f(n).
Show answer
Compare n^(log_b a) with f(n): if f(n) is much smaller, T(n) is n^(log_b a); if equal, multiply by log n; if much larger, T(n) is f(n).
- When does Master Theorem Case 1 apply?
Show answer
When f(n) is O(n^(log_b a - epsilon)) for some epsilon > 0, making T(n) = Theta(n^(log_b a)).