Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Finding a cheap flight Imagine you graduated and got a job at stingyflights.com. Your task is to design an algorithm for finding cheap flights.

image text in transcribed

3. Finding a cheap flight Imagine you graduated and got a job at stingyflights.com. Your task is to design an algorithm for finding cheap flights. You are given a list of n cities, and a list of m flights between them. For each flight i, you are given its departure city Xi, its destination city yi, its departure time ti, its duration di, and its cost ci. So flight i departs from city ri at time t,, arrives at city y, at time ti+di, and costs ci dollars Design an algorithm that given a pair of cities a, b, computes the cheapest possible route (i.e. sequence of flights) that starts at a at time 0, and ends at b at time at most T The running time of your algorithm should be polynomial in n and m (e.g. O(n10m5 Hint: Express the above problem as shortest-path computation in some graph. 3. Finding a cheap flight Imagine you graduated and got a job at stingyflights.com. Your task is to design an algorithm for finding cheap flights. You are given a list of n cities, and a list of m flights between them. For each flight i, you are given its departure city Xi, its destination city yi, its departure time ti, its duration di, and its cost ci. So flight i departs from city ri at time t,, arrives at city y, at time ti+di, and costs ci dollars Design an algorithm that given a pair of cities a, b, computes the cheapest possible route (i.e. sequence of flights) that starts at a at time 0, and ends at b at time at most T The running time of your algorithm should be polynomial in n and m (e.g. O(n10m5 Hint: Express the above problem as shortest-path computation in some graph

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions