0
1.3kviews
What are the advantages of using linked lists over an array
1 Answer
0
3views
  1. Dynamic size As the size of linked list is not fixed so we can add or remove as much elements as required. But in array we have to pre-define the array size which we can’t change later.
  2. Ease of insertion/deletion

    i. Inserting a new element in an array of elements is expensive; because room has to be created for the new elements and to create room existing elements have to shift.

    ii. For example, suppose we maintain a sorted list of IDs in an array id []. id [] = [1000, 1010, 1050, 2000, 2040, …..].

    iii. And if we want to insert a new ID 1005, then to maintain the sorted order, we have to move all the elements after 1000 (excluding 1000).

    iv. Deletion is also expensive with arrays until unless some special techniques are used. For example, to delete 1010 in id [], everything after 1010 has to be moved.

Please log in to add an answer.