whats the difference between an array-based queue a nd a linked list based queue.
Orely
whats the difference between an array-based queue a nd a linked list based queue.
Orely
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.
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?