Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 4 ( Shared - Bus Take II ) . ( 2 0 points ) Remember how you helped the famous ride - sharing company
Problem SharedBus Take II points Remember how you helped the famous ridesharing company Ubyft to created a new "sharedbus" service during the first midterm? Well that didn't work very well. Turns out that the customers don't like to specify two points, they just want to give a single destination. Ubyft is redesigning their algorithm and they need your help.
The bus runs on a path, each point on the path is denoted by its distance from the starting point. In this new problem, there are passengers. They all board the bus at the starting point Passenger i specifies a destination where the passenger wants to go You can assume that the s are already sorted in increasing order.
If passenger i leaves the bus at a position then the "unhappiness" of the passenger is
Similar to the previous problem, there are no fixed bus stops. Instead, the stops will be decided after gathering the user information. The bus can make at most stops, and your goal is to design an algorithm that minimizes the sum of unhappiness of all the passengers.
As an example, if there are passengers with with and then the optimal solution will make two stops at points and The first stop serves the first passenger; the second stop serves the remaining three passengers. The unhappiness for passengers are respectively and the total unhappiness is
a points Define the state subproblems write the transition function and specify the base cases.
b points Design an algorithm for finding the locations where the bus needs to stop. Your algorithm only needs to output the optimal total unhappiness of the passengers Analyze the running time of your algorithm. Your algorithm should run in 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