Link to home
Start Free TrialLog in
Avatar of javamate06
javamate06

asked on

Queues Implementation


How to implement queues in C, can we do it as array or is there a built in way to do it?
If there is, what about pop and push methods?
Avatar of imladris
imladris
Flag of Canada image

No built in facilities. You have to implement it yourself.

If you can use C++ there is some stuff in the template library that would help.
ASKER CERTIFIED SOLUTION
Avatar of grg99
grg99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi,

You can Impliment in two ways,

1. Linear implimentation
2.Circular Implimetation

These two also you can impliment through Arrays or Linked List.

Refer the following URL you will get an idea abt the implimentation
http://www.c.happycodings.com/Data_Structures/code16.html
http://www.wol.net.pk/mtshome/cppDataStructures.html

Deepu
Avatar of cup
cup

The implementation is the same as that of a linked list except that adding (pushing) always adds to the tail and removing (popping) always removes from the head.  There are pros and cons as to whether a singly linked list or a doubly linked list is faster.  I normally use a doubly linked list as I tend to traverse both ways.

You may also see something called a dequeue: a double ended queue.  This is quite a strange one: you can add to both the head and tail and remove from both the head and tail.
Avatar of F. Dominicus
You can find an implementation of Queues in glib. See e.g.
http://developer.gnome.org/doc/API/2.0/glib/glib-Double-ended-Queues.html

Regards
Friedrich