There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreover, it turned out that the station could be only a dead-end one (see picture) and due to lack of available space it could have oniy one track. 5, 4, 3, 2, 1 1, 2, 3, 4, 5 B. Station The local tradition is that every train arriving from the direction A continues in the direction B with coaches reorganized in some way. • Assume that the train arriving from the direction A has NE 1000 coaches numbered in increasing order 1, 2. . N. • The chief for train reorganizations must know whether it is possible to marshal coaches continuing in the direction B so that their order will be a. a. . aN. Help him and write a program that decides whether it is possible to ge: the required order of coaches. • You can assume that single coaches can be disconnected from the train before they enter the station and that they can move themselves until they are on the track in the direction B. • You can also suppose that at any time there can be located as many coaches as necessary in the station. But once a coach has entered the station it cannot return to the track in the direction A and also once it has left the station in the direction Bit cannot return back to the station. Program Input • The input file consists of blocks of lines, each of which is a test case. Each block except the last describes one train and possibly more requirements for its reorganization. In the first line of the block there is the integer N. which is the number of coaches in the train, In each N.For example, if N is 5, and the permutation could be 5, 3, 2. 1.4. Your program will take this permutation as input and of the next lines of the block there is a permutation of 1, 2, determine whether you can marshal the coaches from track A an incoming order 1, 2, 3, 4, 5 to track B with an outgoing order 5, 3. 2, 1,4 using the station, which can be treated as a stack • The last line of the block contains just 0. • If a block starts with a zero, the program will terminate. • You should use the input file named lablin.txt (download from Canvas) to test your program; an output file named lablout.txt (with correct output) is also provided for you to verify your program.
There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreover, it turned out that the station could be only a dead-end one (see picture) and due to lack of available space it could have oniy one track. 5, 4, 3, 2, 1 1, 2, 3, 4, 5 B. Station The local tradition is that every train arriving from the direction A continues in the direction B with coaches reorganized in some way. • Assume that the train arriving from the direction A has NE 1000 coaches numbered in increasing order 1, 2. . N. • The chief for train reorganizations must know whether it is possible to marshal coaches continuing in the direction B so that their order will be a. a. . aN. Help him and write a program that decides whether it is possible to ge: the required order of coaches. • You can assume that single coaches can be disconnected from the train before they enter the station and that they can move themselves until they are on the track in the direction B. • You can also suppose that at any time there can be located as many coaches as necessary in the station. But once a coach has entered the station it cannot return to the track in the direction A and also once it has left the station in the direction Bit cannot return back to the station. Program Input • The input file consists of blocks of lines, each of which is a test case. Each block except the last describes one train and possibly more requirements for its reorganization. In the first line of the block there is the integer N. which is the number of coaches in the train, In each N.For example, if N is 5, and the permutation could be 5, 3, 2. 1.4. Your program will take this permutation as input and of the next lines of the block there is a permutation of 1, 2, determine whether you can marshal the coaches from track A an incoming order 1, 2, 3, 4, 5 to track B with an outgoing order 5, 3. 2, 1,4 using the station, which can be treated as a stack • The last line of the block contains just 0. • If a block starts with a zero, the program will terminate. • You should use the input file named lablin.txt (download from Canvas) to test your program; an output file named lablout.txt (with correct output) is also provided for you to verify your program.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
I asked the same question twice and I still haven’t got a code that works please provide one
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY