This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between random access data and sequential acces.

 
Prashant Neginahal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
what is difference between "random access" data store (such as an array) and sequential access data (such as a linked list)?
I got this doubt while reading difference between AbstractList and AbstractSequentialList, two abstract classes.
Hope somebody will help me..
 
Arvind Varma
Ranch Hand
Posts: 48
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These terms have more to do with how elements are stored.
Random Access - Is self explanatory in the sense you can access elements without worrying about how they are stored. The cost of accessing the element is always constant(independent of number of elements)
Sequntial Access - You need to traverse a list to access a particular object. Depending on how the elements are stored will affect the way you access it. The cost in this case may vary from 1(case when ur searching for first element) or 'n'(case when ur searching for last element)
Do post ur views if ur still not clear about it
Thanks
 
Abhijeet Bhanjadeo
Greenhorn
Posts: 5
AngularJS Flex Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Citing implementation about them:
With an array, you can use the array index to access any element immediately. This is called random access.
Whereas,
With a linked list, you have to start at the top of the list and then move from node to node until you get to the node you want, which is termed sequential access.

References:
LinkedList Vs Array
Random_Access

Additional read:
java.util.RandomAccess is marker class that is used to indicate that they(Collections) support fast (generally constant time) random access.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic