Solved

queue's

Posted on 2002-04-04
3
285 Views
Last Modified: 2010-03-31
i would like to know what are are the advantages and disadvantages of

Queues implemented as an array
Queues implemented with nodes and pointers


i am a newbie so please explain a bit and examples would be great!

thank you for your help!!!

steven
0
Comment
Question by:stevenglass
  • 2
3 Comments
 
LVL 4

Expert Comment

by:m_onkey_boy
ID: 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.
0
 

Accepted Solution

by:
SreedharSanni earned 75 total points
ID: 6920607
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
0
 
LVL 4

Expert Comment

by:m_onkey_boy
ID: 6921321
echo?
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now