References and Array to create a linked list data type structure

Hi,

What are the basic advantages and disadvantages of using an array or references to create a linked list data type structure in Java?

Any help appreciated.

Thanks
nhay59Asked:
Who is Participating?
 
wynhamacConnect With a Mentor Commented:
Well as I understand it, current implementations are like this.

An ArrayList will allocate chunks of memory (create another array) at a time as needed when your data set needs it.  This could use up more memory than you need to but provides for quicker access and iteration.

A LinkedList uses nodes it will only use as much memory as the number of elements you have.  However, iteration and indexing may require traversing these nodes which takes longer.

Simply put, use arrays when you have large data sets that need to be indexed or iterated over and use reference nodes for smaller data sets where you don't want to use more memory than you need and iterating or indexing will have minor impact on performance.
0
 
CEHJCommented:
As i mentioned in your earlier question, an array is not suitable, since it is inherently fixed size. A lightweight node object is commonly used instead, containing a next pointer
0
 
hoomanvConnect With a Mentor Commented:
> using an array to create a linked list
linked list is implemented by nodes which are linked to each other
you cant implement linked list with array
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
hoomanvCommented:
0
 
nhay59Author Commented:
Hi,

Yes, I'm sorry. My fault.

If the list was fixed, therefore some basic 'list' data type, what would be the advantages and disadvantages for implementing and representing this in Java using an array or references to create a linked structure? Is this possible?

Thanks for the help.
0
 
CEHJConnect With a Mentor Commented:
Really a 'list' implies something that is dynamic so it's distinct from an array
0
 
nhay59Author Commented:
Hi,

Thanks to all for their replies and help. Much appreciated.

Have a great week.
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.