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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f58c8e4e625_33366f58c8df253f.jpg)

[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
Get step-by-step solutions from verified subject matter experts
