Thread: About Queues

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    About Queues

    Hello Guys,

    I have some questions about Queues, their are pointers in queues eg.
    "front" and "rear". front is a pointer which points to the 1st element of the queue and rear is a pointer which points to the last element or data inserted in the queue.

    I am actually making a program on bank which has counters and also has tellers. The purpose of teller is to serve the customer at the counter.

    I wanted to know that can I declare the front and rear pointers in the Queue program as :

    "int *front" and "int *rear" ?

    thanks
    Last edited by student111; 11-27-2013 at 08:14 AM. Reason: adding more

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    If they are indices into an array of values, no.
    If you're making a queue with a (doubly?)linked list, yes.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    96
    thanks for your reply,
    but do we have to use doubly linked list for such programs? will not singly linked list be useful in this case?

  4. #4
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Sure, but you have to remember to remove from the 'head' of the list and put stuff in the other end.
    But, if you need a double ended queue, it'd be a poor idea to use a singly linked list.

  5. #5
    Registered User
    Join Date
    Apr 2013
    Posts
    1,658
    You can use a single linked list or an array (circular buffer) for queue. If it's a list, then head and tail are pointers, if it's an array, then head and tail are indices.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help with Queues
    By Hikaru90 in forum C Programming
    Replies: 5
    Last Post: 03-14-2010, 08:55 AM
  2. queues
    By rebelfirst in forum C++ Programming
    Replies: 9
    Last Post: 12-02-2007, 05:33 AM
  3. Regarding queues!!
    By coolkarthik20 in forum C Programming
    Replies: 2
    Last Post: 06-13-2007, 05:08 AM
  4. Queues
    By ramayana in forum C Programming
    Replies: 22
    Last Post: 01-01-2006, 02:08 AM
  5. queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-11-2001, 05:19 PM