Implementing a Custom Linked List
A list has two implementations:
ArrayList: This is implemented using arrays as the underlying data structure. It comes with the same limitations as arrays.
Linked List: Elements in linked lists are distributed across the memory, contrary to in an array, where they are contiguous.
Disadvantages of ArrayList
Disadvantages of ArrayList are as follows:
Though ArrayList is dynamic and the size need not be mentioned during creation. However as the size of arrays is fixed, therefore ArrayLists often need to be implicitly resized when more elements are added to the list. Resizing follows the procedure of creating a new array and adding all the elements of the previous array into a new array.
Inserting a new element at the end of the ArrayList is often faster than adding in between, however, it's expensive when elements are added in between the list, because room has to be created for the new elements, and to create room existing elements have to shift.
Deleting the last...