Question: [10 marks] Greedy algorithm. Here is a special matching problem: given a set A of n numbers and a set B of n numbers, form

 [10 marks] Greedy algorithm. Here is a special "matching" problem: given

a set A of n numbers and a set B of n

[10 marks] Greedy algorithm. Here is a special "matching" problem: given a set A of n numbers and a set B of n numbers, form pairs (a1,b1),,(an,bn), with {a1,,an}= and {b1,,bn}=B, so that the following cost function is minimized i=1n(aibi)2 Consider the following "greedy" strategy to solve this problem: pick the pair (a,b) with the smallest difference ab(aA,bB). Then remove a from A and b from B, and repeat. (a) Give a counterexample showing that this strategy is incorrect, i.e., it can sometimes give a non-optimal solution. Show your work! (b) Give another greedy strategy that will solve this special matching problem (detailed pseudocode is required). Prove that it always returns an optimal solution. Justify correctness and analyze running time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!