Monday 9 April 2012

ArrayList vs LinkedList

Both implements List interface.

       1) ArrayList is implment re sizable array.
       2) LinkedList is implment doubly Linkedlist.

Difference.

       1) Data structure of both is different.
       2) ArrayList - Getting and searching operation is fast(Getting from array index), Where remove opeation is too costly since it require rearrange all the index.
       3) On linkedList we need to iterate through all elements, Does not provide random or indexed base access.
       4) Insertion are very easy in Linkedlist since its not reuqire to rearranging an index.
       5) Linkedlist is more over head then arraylist, Since the node have data and address of the next and previous data.

When to use LinkedList:

                Since application inserts or remove more than retrieval then Linkedlist  is better option.
                If application can live with out random data access then Linkedlist is better option.

No comments:

Post a Comment