Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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