FlashKeepers

Computer Science · College · College and University

Algorithms: Greedy and Divide and Conquer

Greedy choice property, interval scheduling, Huffman coding, merge sort, the master theorem, closest pair and Strassen.

About this set

39 basic cards for College Computer Science. Set 3 of 5 in Algorithms. It opens with "What is the greedy choice property?" and "When does a greedy algorithm guarantee an optimal solution?". Study it alongside the other College sets below.

39 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is the greedy choice property?
Show answerA 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 answerWhen 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 answerAlways select the interval that finishes earliest.
What is an exchange argument in algorithm analysis?
Show answerA proof technique showing that any optimal solution can be transformed into a greedy solution without losing optimality.
What does Huffman coding produce?
Show answerA prefix-free binary encoding where more frequent characters use shorter codewords.
What are the steps to build a Huffman tree?
Show answerRepeatedly combine the two nodes with smallest frequencies into a new node until one tree remains.
Why are Huffman codes called prefix-free?
Show answerNo codeword is a prefix of any other codeword, enabling unique decoding.
Why is Huffman coding optimal among all prefix-free codes?
Show answerIt minimizes the expected codeword length because it places less frequent characters deeper in the tree.
What is the divide phase of merge sort?
Show answerRecursively split the array in half until each subarray has one element.
What is the conquer and merge phase of merge sort?
Show answerMerge adjacent sorted subarrays by comparing elements and placing the smaller one first.
What is the time complexity of merge sort?
Show answerO(n log n) in all cases: best, average, and worst.
What is the space complexity of merge sort?
Show answerO(n) because merging requires auxiliary arrays.
Is merge sort a stable sorting algorithm?
Show answerYes, equal elements maintain their original relative order.
State the Master Theorem for recurrences of the form T(n) = aT(n/b) + f(n).
Show answerCompare 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 answerWhen f(n) is O(n^(log_b a - epsilon)) for some epsilon > 0, making T(n) = Theta(n^(log_b a)).

24 more cards in the app

Study this set free