Thread: Queue

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    6

    Queue

    Can somebody show me how to make queue algorithm? How many kind of queues in programming? how to make a fast queue algorithm.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    If you know how to makea linked list then you know how to make a Queue. Its late now and im gonna hit the sack so no code until 2moro but the idea is simple.....

    make linked list
    keep track of tail of list and head of list by pointers
    add new events to tail of list -> update tail pointer
    pull new events from head of list ->update head pointer.

    simple. you now have a linked list that operates as a first in first out structure.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Look in a good data structures book. There are many examples of variations of the Queue ADT.

    Mr. C.

  4. #4
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    Actually, a queue and a linked-list are not the same thing.

    A queue normally consists of an array of consecutive, adjacent memory objects (like an array of chars or longs or structs). Then two pointers are used. One for head and one for tail.

    Data is poked into the queue via one pointer and removed via a second pointer. One is usually called the 'head' pointer and the other the 'tail' pointer.

    The concept can be applied to linked lists, but really, a linked list is a linked list.
    It is not the spoon that bends, it is you who bends around the spoon.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    6

    example

    show my an example please.
    thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 08:17 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  4. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 11:39 AM
  5. queue help
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-29-2001, 09:38 AM