top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why insertion and deletion in ArrayList is slow compared to LinkedList Please explain with example?

0 votes
546 views
Why insertion and deletion in ArrayList is slow compared to LinkedList Please explain with example?
posted Mar 30, 2016 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

ArrayList is slower because it needs to copy part of the array in order to remove the slot that has become free. If the deletion is done using the ListIterator.remove() API, LinkedList just has to manipulate a couple of references; if the deletion is done by value or by index, LinkedList has to potentially scan the entire list first to find the element(s) to be deleted.

answer Apr 5, 2016 by Shubham Singh
...