Mid-Term 2 Flashcards
In general what are the two properties we need to prove that our greedy algorithm is optimal?
We need to prove the two following properties: 1) Greedy-choice property 2) Optimal substructure property
How do you prove the Greedy-choice property?
We are trying to prove that there exists an optimal solution for P that contains the greed choice made in the algorithm.
Proof of greedy-choice property: Assume that there is an optimal solution V that doesn’t make the same choice as our greedy choice. Prove that it makes a worse choice
How do you prove the optimal sub-structure property?
Optimal sub-structure property means that if we were to remove any choice we made from the solution, the resulting set is the optimal solution for this new subproblem.

In general, how is a knapsack problem defined?

Fractional Knapsack:
What is the input?

Fractional Knapsack:
What is the definition of a feasible solution?

Fractional Knapsack:
What is the required output?

Spell out the greedy choice made by densist-first algorithm for fractional knapsack.
What is the case 1?

Spell out the greedy choice made by densist-first algorithm for fractional knapsack.
What is the case 2?

Provide the proof for case 1: smax > k

Provide the proof for case 2: smax<= k

What is the goal of proving the optimal substructure property? What is the typical proof structure?

State case 1 of the master theorem.
What does it mean?

State case 2 of the master theorem.
What does it mean?

State case 3 of the master theorem.
What does it mean?

What is the following for mergeSort
Divide
Conquer
Combine

Write out how mergeSort would sort the following:


What is the mergesort code?

What is the formula for merge sort and what is the subsequent run time?

What is the pseudo code to implement Densest-First for the frational knapsack problem?

How do we analyse the running time of Densist-First fractional knapsack?
What is the run time?

What is the brute force calculation of fractional knapsack?

What is the brute force calculation of 0-1 knapsack?
The number of choice would be 2n possible solutions
We can always brute force an answer but the running time is Ω(2n) which is extremely slow
As an example, see below
