Train reorganising, Data Structure & Algorithms

Assignment Help:

A freight train from Melbourne is approaching Sydney, carrying n cars of cargos. The cargos are to be delivered to n different cities in the metropolitan area of Sydney - one car for one city. To avoid delays of stoping at each city station, the train is to dismiss a car once the car arrives its destination station without unloading the car, providing the car was at the end of the train. Since all these cars of the train were collected on the way from Melbourne to Sydney, the order of these cars does not match the order of their designations. The train have to be reorganised in the Railway Switching Junction outside Sydney to reorder its cars to match the order of their destinations (See Figure). The aim of this assignment is to design and implement an algorithm to simulate the procedure of car re-ordering. 

1646_Train Reorganising.png

The above figure shows the diagram of the railway switching junction. The junction has a single entrance and a single exit on the main railway from Melbourne to Sydney. There are k transit rails, denoted by T1, T2, ..., and Tk, linked to the main railway for a train to transfer cars. The train can drive in or out each transit rail either forward or backward.

The train can be disconnected at any point between two cars. A car can be parked in a transit rail but cannot be left on the main track. A car cannot move without connecting to the engine (only one engine). We assume that the transit rails and their distance in between are long enough for the train to drive in and out in full length.

Assume that the destination stations in Sydney are labelled from 1 to n, arriving Station n first and ending at Station 1. Each car of the train is marked in accord with its destination.

When the train arrives, the order of the cars from the engine to the last car is c1,c2,...,cn, which can be any permutation of the numbers 1,2,...,n. As an example shown in Figure 1, when the train arrives the junction, the order of the cars is 4,3,5,1,2. The cars need to be re-ordered into 1,2,3,4,5 to be delivered at their destination stations.


Related Discussions:- Train reorganising

Methods of physically storing data in the files, This unit dealt along with...

This unit dealt along with the methods of physically storing data in the files. The terms fields, records & files were described. The organization types were introduced. The sev

Data communication, #question.explain different types of errors in data tra...

#question.explain different types of errors in data transmission.

Hasing and indexing, differentiate between indexing and hashing in file org...

differentiate between indexing and hashing in file organization

Sort list of distinct numbers in ascending order - quicksort, (1) Sort a li...

(1) Sort a list of distinct numbers in ascending order, using the following divide- and-conquer strategy (Quicksort): divide the list of numbers into two lists: one that contains a

Explain the prim''s minimum spanning tree algorithm, Question 1. Explai...

Question 1. Explain the different types of traversal on binary tree 2. Explain the Prim's minimum spanning tree algorithm 3. Differentiate fixed and variable storage allo

Explain the term totalling, Explain the term totalling To add up a ser...

Explain the term totalling To add up a series numbers the subsequent type of statement must be used: Total = total + number  This literally means (new) total = (old) t

Sort 5, The number of interchanges needed to sort 5, 1, 6, 2 4 in ascending...

The number of interchanges needed to sort 5, 1, 6, 2 4 in ascending order using Bubble Sort is 5

Which is the most suitable data type, Problem 1. You are asked to store...

Problem 1. You are asked to store Names of all 100 students of class A in your Learning Centre. Which data type will you use? What is its syntax? Explaining the data typ

State a algorithm that inputs the heights of all 500 student, As part of an...

As part of an experiment, a school measured heights (in metres) of all its 500 students. Write an algorithm, using a flowchart that inputs the heights of all 500 students and ou

Array implementation of a dequeue, If a Dequeue is implemented via arrays, ...

If a Dequeue is implemented via arrays, then this will suffer with the similar problems which a linear queue had suffered. Program 8 gives the array implementation of Dequeue.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd