-3

I am confused because both of these contain an index, so a indexed linked list has nodes and indexes? While array list only has indexes?

daisygal
  • 33
  • 1
  • 6
  • 1
    Possible duplicate of [When to use LinkedList over ArrayList?](http://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist) – Yahya Apr 29 '17 at 19:58
  • I looked at that link, and it only talks about linked lists in general...but what about specifically a indexed linked list? – daisygal Apr 29 '17 at 20:00
  • where did you find such a data structure in the first place? – JB Nizet Apr 29 '17 at 20:01
  • 1
    Related: [Is there a known implementation of an indexed linked list?](http://stackoverflow.com/questions/1712952/is-there-a-known-implementation-of-an-indexed-linked-list) – Ole V.V. Apr 29 '17 at 20:01
  • 1
    What do you mean by an "indexed linked list"? Are you asking specifically about `java.util.LinkedList`? – John Bollinger Apr 29 '17 at 20:03

1 Answers1

0

ArrayList is continuous representation of the data .

So if base addr is lets say 64 and you want a element at 4th index and size of each element is 4 bytes so by doing the math we can say at what memory addr to look for 4th index element . So we can land at up at the element directly

On the other hand Linked List we have to traverse node by node and by counting the numbers of node traversed .

SO index works for both of them.For arraylist we can access it directly but in Linked list we have to traverse the intermediate nodes

Vikrant
  • 178
  • 4