Why is the insertion and deletion of ArrayList less efficient than LinkedList?

ArrayList is based on an array. When deleting, the get position is O (1), and the delete complement is O (n).
LinkedList is based on a linked list, and when deleted, the location is O (n), and the deletion is O (1). The operation of
inserts is the same.
it doesn"t make any difference if you look at it this way. It is said in "Java data structure and algorithm" that using Iterator can solve the inefficient problem of LinkedList deletion operation.

Why is LinkedList more efficient? Why does Iterator save more time than traversing the linked list sequentially?


first of all, let's be clear: ArrayList traverses faster with for loops than iterator iterators, and LinkedList traverses faster with iterator iterators than for loops.
as to why Iterator saves time than traversing the linked list sequentially , my understanding is that because arrayList is based on arrays and the subscript is clear, get (i) is very efficient when using for loops;
while linkedList based on linked list, get (i) complexity is O (n), plus the number of loops is O (n ^ 2), but using iterator.next () does not need subscript, only the complexity of the loop can be counted

.
Menu