HI, I'm on my last assignment of the semester and I'm pretty stuck on how to get this started.. Can anyone point me in the right direction? This is my first programming class so its been pretty tough for me.
You are to simulate the train arriving at the switching yard as a queue. Each of the trains you are assembling, each on its own side rail, is to be modeled using a stack. You are allowed to add a new function to the queue code named Peek(), that lets you look at the information contained in the first node of the queue without dequeueing it.
You are required to have functions called DestroyStack() and DestroyQueue() which will destroy these data structures when you are finished using them by freeing all of the nodes and setting the heads to NULL.
You are to use an input data file that will contain information about each of the cars in the arriving train, in order of their occurrence in the train. Each car's information will consist of the following, in this order:
carNum cargo origin destination weight miles
Here is the contents of a sample data file called arriving.dat:
45301 coal Pittsburgh Baltimore 13000 229
57321 cattle Lancaster Trenton 5000 198
82353 hogs York Trenton 3500 181
77443 eggs Lancaster Charlotte 1500 481
39115 coal Pittsburgh Norfolk 13500 451
27145 coal Pittsburgh Norfolk 13700 451
81123 autos Detroit Baltimore 27000 477
32492 hogs Lancaster Trenton 3750 198
65230 eggs Lancaster Newark 1600 245
37220 coal Pittsburgh Roanoke 13600 495
72413 autos Detroit Trenton 26500 610
49374 autos Detroit Charlotte 27300 893
92949 eggs Lancaster Charlotte 1550 481
If we refer to the main line as track 0, then we want to build a new train on the side-rail referred to as track 1 that contains only cars destined for Trenton. Track 2 will contain cars destined for Charlotte. Track 3 will contain cars destined for Baltimore. Track 4 will contain cars that are going to other destinations.
You must use the linked-list implementations of both the stack and the queue. Use of array implementations of stacks and queues will receive NO credit.
THANKS FOR ANY INPUT!