Benefits of Linked List over Array:
1.Deletion and Insertion:
-> Deletion and Insertion in linked is less time consuming over array.
Deletion:
if we delete any element from array except last element, then we have to shift all element backward after the deleted element. so suppose we have an array of 10 integers and if we delete element from index five, then we have to shift element from index 6 to 9 backward. and it will consume more time.
while deletion in list is less time consuming. we will see it later.
Insertion:
if we insert an element in the array except last index, then we have to shift the remaining element after that index towards right. and it will take more time. while insertion in linked list is much profitable than array.
2.We can dynamically increase the size of the linked list as we allocate memory to nodes at runtime(or dynamically). while in case of array we have to declare it size during writing of code. but now in C++
we have vector for dynamic memory allocation.
next tutorial:
Comments
Post a Comment