Inserting an element in a Linked List is easy, but in an array it may be time consuming. For example: if we have a sorted array (of size 10) like below (last 4 positions are empty which are represented by _):
2 4 6 8 10 15 _ _ _ _
and we want to insert 7 in this sorted array, then we have to shift 3 elements by one position.
2 4 6 7 8 10 15 _ _ _
In case of linked list pointers could have been manipulated and no shifting would have been required.
Next: Deleting element …
1 Comment
why we can not use binary search in linked list even it is sorted,what is main reason behind this fact?