answersLogoWhite

0


Best Answer

A linked list is better bcoz:

1. A linked list can be grown to any size whereas a statically allocated array is of a fixed size and hence can cause problems if you try to insert beyond that.

2. Deletion of elements is a problem in arrays. You either have to move all the elements following the deleted element forward which is a waste of time or you have to place a sentinel indicating that the element in that position is deleted which causes a waste of space.

On the flip side, arrays are easier to handle because their memory allocation is done once and for all(atleast till you need more space and have to reallocate) and because there is no hassle with pointers.

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

The main disadvantage of a linked list is access time to individual elements. An array is random-access, which means that there is a O(1) to access any element in the array. Linked lists do not share this, and have a O(n) for access to an element in the list.

Another advantage of arrays in access time is spacial locality in memory. Typically arrays are defined as contiguous blocks of memory, and so any array element will be physically near its neighbors. This greatly benefits from modern CPU caching methods.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Access times for non-sequential access:

Singly linked list, if you need to access a specific node, you have to iterate left until you reach your destination (relative of the position of your current iterator)

e.g. if you have a list with 5 ordered values ->1->2->3->4->5-> and your current pointer is on 3; you will need 4 hops to get to value 2

Doubly linked can make it a bit faster, because now you can go either direction to get to the specific node.

e.g. if you have a list with 5 ordered values <->1<->2<->3<->4<->5<-> and you are on value 4, it will still take you 2 hops to get to 2

Because of the nature of the array, any element's location in ram can be determined mathematically, meaning that access to any value is a little math + 1 hop away.

Linked lists tend to have a larger memory foot print:

However it is not right to say that they always do. Like everything in computing, it really depends on the implementation. But in general because in a list every node has a pointer at least to the next node, and arrays go off memory offsets and thus save a pointer per node, arrays tend to be leaner.

It must be added that the previous contributor's answer above is based on the assumption that an array's element's location can be computed using simple arithmetic. While this is true for many traditional programming languages, most modern programming languages and runtime libraries provide implementations of an array which are based on linked lists or hash tables. This is done in an effort to preserve the performance characteristics of traditional arrays, while supporting more modern requirements, such as support for jagged multi-dimensional arrays, variable-size arrays and associative arrays.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Linked lists take extra memory for storing the addresses. Linked lists have an access time of O(n), arrays have an access time of O(1).

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

tae ksa

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Rashesh

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are disadvantages of a linked list over an array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the advantages of linked list over arrays?

# Linked lists do not need contiguous blocks of memory; extremely large data sets stored in an array might not be able to fit in memory. # Linked list storage does not need to be preallocated (again, due to arrays needing contiguous memory blocks). # Inserting or removing an element into a linked list requires one data update, inserting or removing an element into an array requires n (all elements after the modified index need to be shifted).


Convert single linked list to double linked list?

You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.


Advantage of linked list over array?

The only real advantage a linked list has over an array is that it can grow much more efficiently, however this is only guaranteed when new elements are inserted at the head or the tail of the list where you have constant time access. Constant time random access is not possible, thus insertions within the body of the list may be slower than for an array because of the need to traverse to the insertion point. However an array must reallocate in order to make room for new elements which may result in the entire array being moved to new memory. This can be minimised by reserving memory in advance. But, more importantly, all elements from the insertion point must be moved forward in the array in order to make a gap for new elements. Thus inserting into an array can often be slower than for a list, particularly if the elements do not support move semantics (they must be copied instead). If you plan on performing many such insertions, then a list will probably be quicker overall because there is no need to move elements around in memory. However, if you require random access and compact storage, use an array instead and reserve as many elements as you require for your insertions.


What are the merits and demerits of array based implementation over linked implementation?

The merits of an array are that it provides the most compact storage mechanism of any data container, and enables constant-time, random access to that data. The demerits are that insertions and extractions can be costly in terms of performance due to the need to copy/move elements within the array. For large arrays, the cost can become prohibitive. Also, arrays can only be used to store elements of the same type.


What advantages of a sorted list over a linked list?

All lists are linked lists; there is no such thing as a separate "sorted list". There are algorithms that can sort a list, of course, but they all work on linked lists.

Related questions

What are the advantages of linked list over arrays?

# Linked lists do not need contiguous blocks of memory; extremely large data sets stored in an array might not be able to fit in memory. # Linked list storage does not need to be preallocated (again, due to arrays needing contiguous memory blocks). # Inserting or removing an element into a linked list requires one data update, inserting or removing an element into an array requires n (all elements after the modified index need to be shifted).


Advantage of linked list over array?

The only real advantage a linked list has over an array is that it can grow much more efficiently, however this is only guaranteed when new elements are inserted at the head or the tail of the list where you have constant time access. Constant time random access is not possible, thus insertions within the body of the list may be slower than for an array because of the need to traverse to the insertion point. However an array must reallocate in order to make room for new elements which may result in the entire array being moved to new memory. This can be minimised by reserving memory in advance. But, more importantly, all elements from the insertion point must be moved forward in the array in order to make a gap for new elements. Thus inserting into an array can often be slower than for a list, particularly if the elements do not support move semantics (they must be copied instead). If you plan on performing many such insertions, then a list will probably be quicker overall because there is no need to move elements around in memory. However, if you require random access and compact storage, use an array instead and reserve as many elements as you require for your insertions.


Convert single linked list to double linked list?

You copy a singly linked list into a doubly linked list by iterating over the singly linked list and, for each element, calling the doubly linked list insert function.


Adavantage of pointer based of a list over an array?

One advantage of a linked list (with pointers) is that it is fairly cheap to insert or delete an element - once you know where it is. A disadvantage is that getting a specific element - for example, the 1000th. element - is expensive.


What are the merits and demerits of array based implementation over linked implementation?

The merits of an array are that it provides the most compact storage mechanism of any data container, and enables constant-time, random access to that data. The demerits are that insertions and extractions can be costly in terms of performance due to the need to copy/move elements within the array. For large arrays, the cost can become prohibitive. Also, arrays can only be used to store elements of the same type.


What advantages of a sorted list over a linked list?

All lists are linked lists; there is no such thing as a separate "sorted list". There are algorithms that can sort a list, of course, but they all work on linked lists.


Explain any two advantages using Single linked list over Doubly linked list and vice-versa?

Advantages of single linked list: # Decrease in storage space per linked list node # Simpler implementation Advantages of double linked list # Decrease in work when accessing a random node # Decrease in work when inserting or deleting a node


Disadvantages of circular link list as compared to singly link list?

As compared with doubly-linked lists, one disadvantage is that singly-linked lists can only be efficiently traversed in one direction. Finding the (n - 1)th element, given only a pointer to the nth, requires scanning the list from the first element up to the (n - 1)th. Thus (if memory is too limited to permit tricks such as creating a reversed list) to iterate over the entire list in reverse order would require n + (n - 1) + ... + 1 = n(n + 1)/2 link traversals, which grows quadratically with n. Obviously for a doubly-linked list the time merely grows linearly with n.A down-side of all linked lists versus arrays is that random access can be inefficient; the time taken to find an element with a randomly chosen index grows in direct proportion to the list's length (since we must scan from one of the ends). In contrast, an array allows us to index directly to the elements with simple pointer arithmetic, in a time independent of the array's size - at least in an idealised environment.


How do you solve josephus problem using circular linked list?

The Josephus problem is a problem to locate the place for the last survivour. It shows the power of the circular linked list over the singly linked lists.


What are the advantages and disadvantages of DLL over single linked list?

The main advantage of a doubly-linked list is that you can traverse and search the list both forwards and backwards. Although you can also add to the beginning and end of the list, and retrieve the same, in constant time O(1), this is also possible with a slightly modified singly-linked list simply by maintaining a pointer to the last node as well as the first. Thus the only real difference is whether you need to traverse bi-directionally or not. If not, a modified singly-linked list would be more efficient. And if you only require fast access to the first node, a standard singly-linked list would be slightly more efficient.


What are the advantages of HashSet over Array?

Array list and linked list are very effective Data Structures. However, ArrayLists are not effective for adding and removing elements in between and Linked Lists take a lot of time when iterating through the elements. A HashSet is effective in both aspects. However, the selection of HashSet is better if the data we enter needs to be traversed while addition and removing is frequent. Further, HashSet cannot have duplicates. So in places where we need to avoid duplicating data, HashSet would be the key.


Disadvantages of linked lists in c?

Because the C programming language leaves the responsibility for memory allocation and pointers entirely with the programmer, the disadvantage of linked lists over some other linear data structures (such as arrays) is that the bear a risk or memory leaks and invalid pointers. The fact that the size of a linked list is generally not deterministic is also commonly viewed a disadvantage over statically linked linear containers (e.g. arrays) in some systems, primarily in embedded systems. Compared to containers of higher order (such as trees or hash tables), search operations in a linked list are generally slower. Compared to a double linked list, removal and insertion of items (except head and tail) is generally more expensive.