Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started