• 04-15-2009, 06:20 PM
sick_peng
hey im new to the site =) but i just had a question that i asked one of my teachers aid's in class and they wern't able to assist me, i was hoping someone on here might have a better understanding.

we've been talking about queue's in class, and to my understanding a linked list works great just because of how it is structured. but what about an array? i mean yeah an array itself seems like a not so logical way to go about a queue. i read that circular arrays can work just as well.. are there times when you should use a circular array queue over a linked list queue? what is the real difference between the two?? what i was thinking is that it would be easier to find a specific "thing" in a circular array queue acting like a "priority queue" if that makes sense.
• 04-15-2009, 06:30 PM
emceenugget
the difference between a queue using a circular array and linked list is the same as just using an array vs a linked list in most situations, really.

also, a priority queue doesn't work with a single array or list. depending on its actual specs, it can be composed of 2 or more queues, one for each level of priority. sure, you can define one where it uses a single list, but it would be inefficient to have to iterate through it, as opposed to taking advantage of a queue being fifo.
• 04-15-2009, 06:34 PM
sick_peng
true but, if you arrange the array in a circular fashion can't you make it so instead of iterating through everything you can just change what index denotes the head and the tail of the queue??

ex.

array has object at index 1-5;
queue is identified for objects 1-5:

object 1 is removed from queue;
queue is redifined;

array has object at index 1-5;
queue is identified for objects 2-5;

thats kinda what was going through my head....
• 04-15-2009, 06:44 PM
emceenugget
are you still talking about a priority queue?
• 04-15-2009, 06:48 PM
sick_peng
no a priority queue was just something that i thought that maybe an array could be used over a linked list. my question is... is there "ANY" reason or situation where a circular array would be more useful thank a linked list used in any type of queue
• 04-15-2009, 07:17 PM
emceenugget
and to that i replied that the dis/advantages of each are similar to general uses of arrays and linked lists. unless you're implying that there is no reason to ever use an array.
• 04-15-2009, 07:33 PM
sick_peng
aight naw i was just curious guess idk what kind of an answer im looking for haha.. anyway thanks for replying man.