0
1.4kviews
What are the advantages of using linked lists over an array
1 Answer
written 7.9 years ago by |
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.