Help with project using linked-list stack and queues

This is a discussion on Help with project using linked-list stack and queues within the C Programming forums, part of the General Programming Boards category; HI, I'm on my last assignment of the semester and I'm pretty stuck on how to get this started.. Can ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    1

    Help with project using linked-list stack and queues

    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.

    The assignment:

    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!

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    int main( void )
    {
        return 0;
    }
    Start there. You work on it for a while, then let us know when you're having problems, where specifically, and with what aspect.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linked lists, stacks and queues
    By aniramg69 in forum C Programming
    Replies: 10
    Last Post: 11-29-2008, 10:58 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 02:55 AM
  3. Queue Stack Palindrome
    By silicon in forum C++ Programming
    Replies: 20
    Last Post: 07-15-2004, 03:38 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. HEap and stack, I'm confused
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 10-31-2002, 09:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21