Sanjay K.

asked • 05/06/22

How would we use the graph algorithm to justify this runtime of 0(n^2)?

A city consists of a set of n bus stops. There are two main bus lines in the city: the red bus line and the blue bus line. Buses travel between pairs of bus stops. Two bus stops may be connected by either the red bus, the blue bus, both buses, or neither bus. You would like to travel from bus stop X to bus stop Y. You have enough money for one bus ticket, and the bus ticket includes exactly one transfer between bus lines. That means you can leave X on the blue line, and transfer at some point to the red line until you reach Y , or you could travel the entire route on the same bus line, or you can start on the red bus line and then transfer to blue. Your job is to design an algorithm that determines if there is a way for you to get from X to Y using your one ticket. Justify the runtime of O(n^2).

1 Expert Answer

By:

Luke L. answered • 05/07/22

Tutor
5 (17)

[DISCOUNTED PRICE] Experienced developer w/ teaching experience

Sanjay K.

I didn't want it in dynamic programming I wanted it in a graph algorithm ( prim, Kruskal's, dijkstra)
Report

05/09/22

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.