Thursday 25 August 2011

Disadvantages of Linked List



Disadvantages of Linked List:



1.       Memory wastage
2.       No Random Access
3.       Time Consuming
4.       Reverse of Linked List is difficult (Reverese Traverse is difficult)
Heap Space Restriction



Memory wastage:

1.       Pointer requires extra memory
2.       For example if we want to store 3 numbers:
In array: 3 *sizeof(int)= 6 bytes of memory is enough.
In case of Linked List:
3* sizeof(int)+ sizeof(class)=6 bytes+size varies from class to class
3.      
 Random Accessing is not possible:
1.       In array we can go particular element easily by using subscript. In case u want to access 5th element of Array a, simple you can access by writing a[4].
2.       In LL we need access each node sequentially.


3.       Time Complexity:
1.       Since nodes are not stored in the contiguous memory locations, it takes time.
2.       Access time for Individual element is O(n) where as in Array is O(1)

3.       Reverse traversing is difficult:
1.       Single linked list very difficult to traverse linked list from end.
2.       Doubly linked list then though it becomes easier to traverse from end but still it increases again storage space for back pointer.

4.       Heap space Restriction:

Generally objects is allocated in Heap memory.
If there is insufficient space in heap then it will not create any memory.
 



1. Single Linked List
2. Dobule Linked List
3. Circular Linked List
What is Self Referential Class
Disadvantages of Linked List

Stacks using Linked List


No comments:

Post a Comment