Though Queue can be implemented using arrays and pointers,
the implementation type depends on the necessity...
if we know the max size of the queue, it is better we can go with Arrays as handling of arrays is easy.
But when we dont know the size of queue..arrays dont suffice our need so we go for dynamic memory allocation and linking those objects ..which we implement it with Nodes and pointers(in C/C++).
And Java do not have any pointers, it has support for datastructures like java.util.LinkedList etc which will help us in implementating this.
Cheers...
Sreedhar Kumar
Main Topics
Browse All Topics





by: m_onkey_boyPosted on 2002-04-04 at 19:46:29ID: 6919926
A queue implemented with an array has a pre-defined length and this cannot be changed without allocating a whole new array and copying the contents of the original, where a queue implemented with nodes and pointers will grow/shrink as needed.
Java doesn't use the concept of a pointer, though - at least not explicitly.
If you use an array, simply use an array. If you wnat to use the node/pointer approach use java.util.LinkedList as you underlying data structure.