Skip to main content
Advantages and Disadvantages of Linked list
Advantages of linked lists
- we know that size of array is specified at the time of writing the program.this means that the memory space is allocated at compile time.which means we can't increase or decrease it during the runtime according to our needs.if the amout of data is less than the size of the array then the space is wasted ,if the data is more then the size of the array then overflow occurs even if there is enough space available in memory.where as in linked list we dynamically allocat memory.the size of the linked list is not fixed and it can be increased or decreased during runtime.
- Insertion and deletion inside array is not efficient since it requires shifting of elements. In linked list insertion and deletion requires only change in pointers.there is no physical movement of data only the links are altered.
- Flexible memory allocation:linked lists allow for flexible memory alloction,making it easier to manage memory usage.you can allocate memory dynamicallyas needed,rather then having to allocate a fixed amount of memory upfront.
- Ease of implementation:Linked lists are relatively easy to implement,making them a popular choice for many applications.
Disadvantages of Linked lists
- Sequential access: Linked lists provide sequential access to their elements, which means that accessing an element at a specific position requires traversing the entire list. This can make them less efficient for certain applications
- Memory overhead: Linked lists require extra memory to store the pointers that connect the nodes in the list. This can them less memory-efficient than arrays.
- No random access: unlike arrays, linked lists do not allow for random access to elements. To access an element at a specific position, you must traverse the entire list from the beginning.
- Difficulty with reverse traversing: Reverse traversing of a linked list is complex and requires an extra pointer to store the previous node.
Quality of blog is absolutely perfect
ReplyDelete