Google Search

Friday, June 10, 2016

What is disadvantage of using linked lists over arrays?

--The main disadvantage of linked list over array is access time to individual elements.Array is random-access,which means it takes o(1) to access any element in the array.Linked list takes O(n) for access to an element in the list in the worst case.
--Another advantage of arrays in access time is special locality in memory.Arrays are defined as contiguous blocks of memory, and so any element will be physically near its neighbours.This greatly benifits from modern CPU caching methods.
--In linked list , Random access is not allowed. We have to access elements sequentially starting from the first node. So we cannot do binary search with linked lists.
--Extra memory space for a pointer is required with each element of the list.Hence Linked lists wastes memory in terms of extra reference points.

No comments:

Post a Comment