Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tinna is at a train station in America. There are n cities with m trains T 1 , dots, T m that go between cities.

Tinna is at a train station in America. There are n cities with m trains T1,dots,Tm that
go between cities. Train Ti reads from city departure[i] at departure time[i] and
arrives in city arrival[i] at arrival time[i]. Many trains can go between the same cities
and can have different travel times. It takes Tinna no time to switch between reading
at the train station, for example. Tinna can come at time t, switch trains and continue
with a train that leaves at time t. Tinna starts her journey at time t=0. The arrival
times in arrival[i] and departure times in departure[i] are given in "clock hours since
Tinna started the journey." Use Dijkstra's algorithm to find the shortest time it takes
to travel from city A to city B when starting in city A at time t=0.
Iterate over all cities v
v.d= infinite
A.d =0
Q={} # Empty priority queue that holds cities and v.d values
Iterate over all cities v
Q.insert(v, v.d)
while Q.notempty()
v=Q.extractMin()
Iterate over all trains Ti from city v
# (the rest of the algorithm comes here)
image text in transcribed

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

Step: 3

blur-text-image

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago