Question: SOLVE B . A company is planuing to interview 2 n people. Given a 2 - D array costs of size 2 n x 2
SOLVE B A company is planuing to interview n people. Given a D array costs of size n x where costsi is the cost of flying the ith person to city A and costsi is the cost of flying the ith person to city B We want to return the minimum cost to fly every person to a city such that exactly n people arrive in each city.
Example Input: costs Output:
Explanation: The first person goes to city A for a cost of The second person goes to city A for a cost of The third person goes to city B for a cost of The fourth person goes to city B for a cost of The total
minimum cost is to have half the people interviewing in each city. Example Input: costs a points Write down a recursive formulation of the minimum cost, minCostzy which is the minimum cost of sending a people to city A and y people to city B where minCostn n is actually the answer to the original problem. In the solution, consider the possibilities when sending a yt person into a city.
minCostxy Output:
Explanation: The first person goes to city A for a cost of The second person goes to city B for a cost of The third person goes to city B for a cost of The fourth person goes to city A for a cost of The fifth person goes to city B for a cost of The sixth person goes to city A for a cost of The total
minimum cost is to have half the people interviewing in each city.
b points Write a dynamic programming algorithm for finding the minimum cost to fly every person to a city, such that exactly n people arrive in each city. Also, give the running time of your algorithm.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
