Thread: Queues

  1. #1
    Orely
    Guest

    Angry Queues

    whats the difference between an array-based queue a nd a linked list based queue.

    Orely

  2. #2
    Unregistered
    Guest
    A queue is just a container that has been limited to removing the first data it put in first and the last data it put in last. Since both arrays and lists can be configured this way they can both be used for the underlying data container in a queue.

    class queue
    {
    public:
    int pop();
    void push(int);
    int array[10];
    int lastIndex;
    }

    class queue
    {
    public:
    int pop();
    void push(int);
    list mylist;
    }

    The implementation of pop() and push() will differ depending on which underlying container you use. In array you always pop at element zero and push at element lastIndex. With a list you always push at tail and pop at head.

  3. #3
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    an array is a fixed size. a queue is dynamic size.
    you can add to the rear and remove from the front.
    generally you want to use linked lists for queues.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concatenating two static queues?
    By difficult.name in forum C Programming
    Replies: 2
    Last Post: 10-18-2004, 11:19 PM
  2. stacks and queues
    By j0hnb in forum C Programming
    Replies: 4
    Last Post: 04-16-2003, 09:44 PM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  4. queues
    By jamesb in forum C Programming
    Replies: 1
    Last Post: 04-21-2002, 08:57 PM
  5. queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-11-2001, 05:19 PM