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

Explain multidimensional array, Multidimensional array: Multidimensional a...

Multidimensional array: Multidimensional arrays can be defined as "arrays of arrays". For example, a bidimensional array can be imagined as a bidimensional table made of elements,

Sorting, Define Hashing. Store the following values in a hash table of tabl...

Define Hashing. Store the following values in a hash table of table size 11 using division method: 25, 42, 96, 101, 102, 162, and 197. In case of collision, use other hash functio

Calculus, basic calculation for algorith.

basic calculation for algorith.

The space - time trade off, The best algorithm to solve a given problem is ...

The best algorithm to solve a given problem is one that requires less space in memory and takes less time to complete its execution. But in practice it is not always possible to

Comp. sci algorithms, 1. develop an algorithm which reads two decimal numbe...

1. develop an algorithm which reads two decimal numbers x and y and determines and prints out wether x>y or y>x. the input values, x and y, are whole number > or equal to 0, which

Binary search tree (bst), Q. Explain what do we understand by Binary Search...

Q. Explain what do we understand by Binary Search Tree (BST)? Make a BST for the following given sequence of the numbers. 45, 32, 90, 21, 78, 65, 87, 132, 90, 96, 41, 74, 92

Binary tree and binarytree parts, Q. What do you understand by the term Bin...

Q. What do you understand by the term Binary Tree? What is the maximum number of nodes which are possible in a Binary Tree of depth d. Explain the terms given below with respect to

Row major representation, Row Major Representation In memory the primar...

Row Major Representation In memory the primary method of representing two-dimensional array is the row major representation. Under this representation, the primary row of the a

Graph traversal schemes, Q. Explain various graph traversal schemes and wri...

Q. Explain various graph traversal schemes and write their advantages and disadvantages. A n s . Graph Traversal Scheme is explained below In many troubles we wish

Non-recursive implementation of preorder traversal, For preorder traversal,...

For preorder traversal, in the worst case, the stack will rise to size n/2, where n refer to number of nodes in the tree. Another method of traversing binary tree non-recursively t

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