Question
You drive a bus along a road (one line), full of thirsty students and your bus has a soda machine. Every minute a student drinks
You drive a bus along a road (one line), full of thirsty students and your bus has a soda machine. Every minute a student drinks a glass of soda. Your goal is to drop students off quickly at their destinations to minimize soda consumption (in number of glasses consumed). You know the number of students who will get off the bus at each exit. Point of departure of your bus is given (somewhere on the road, not necessarily at the end of the line) and the bus moves at a constant speed of 1km per minute. You have to drive the bus along the road. Suppose you can stop the bus, drop off the students, and drive on. forwards or backwards instantly. Describe an algorithm using dynamic programming to deposit students as they drink as little soda as possible. The input to the algorithm consists of the bus line, i.e. a list of outings with the distance (an integer in km) between successive outings (i.e. the exit positions), the number of students you will drop off at each exit, and the pick-up point. departure of your bus
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