Introduction
,
CSCI-1200 Data Structures — Spring 2018
Homework 5 — Linked Train Cars
In this assignment we examine and manipulate a doubly-linked list structure of different types of train cars:
engines, freight cars, passenger cars, dining cars, and sleeping cars. Each engine weighs 150 tons and has
power = 3,000 horsepower, freight cars hold different weights (depending on the contents of the car), and
all other cars weigh 50 tons. Note that a train can have multiple engines that work together to drive the
train, and these engines can be positioned at the front, the back, or even in the middle of the train! Your
task for this assignment is to perform. a variety of basic train yard operations to connect, disconnect, and
reconnect cars into trains in preparation for service. Please read through the entire handout before beginning
the assignment.
Train Statistics: Speed and Passenger Comfort
Your first task is to calculate the maximum speed of a specific train (a doubly-linked list of TrainCars) on
a 2% incline. A very clearly-written tutorial for this real-world problem is available here:
Overly simplified, the formula for the theoretical maximum relates the overall train weight, the combined
engine horsepower, and the slope incline:
speed
miles
hour
=
total horsepower ∗ 550 lb-feet
sec
∗ 3600 sec
hr
20 lb tractive effort
1% grade
∗ 2% grade ∗ 5280
feet
mile
∗ total weight in tons
Let’s look at an example, using the provided ASCII art printout of a TrainCar linked list: