[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

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
0
nhay59
Asked:
nhay59
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
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
 
hoomanvCommented:
> 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
 
hoomanvCommented:
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
CEHJCommented:
Really a 'list' implies something that is dynamic so it's distinct from an array
0
 
wynhamacCommented:
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
 
nhay59Author Commented:
Hi,

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

Have a great week.
0
 
CEHJCommented:
:-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now