Solved

queue's

Posted on 2002-04-04
3
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

726 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