top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why we need a linked list when we have dynamic array list?

+2 votes
689 views
Why we need a linked list when we have dynamic array list?
posted Feb 15, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes

Because Array take the contiguous memory location, so creates problem to insert or delete a node in between of the memory and to solve that problem link list come in picture.
It can simply store the data any where in memory and just link through their address.

answer Mar 14, 2016 by Ankit Tiwari
0 votes

Linked lists are preferable over arrays for following reasons when :

a) you need constant-time insertions/deletions from the list (such as in real-time computing where time predictability is absolutely critical)

b) you don't know how many items will be in the list. With arrays, you may need to re-declare and copy memory if the array grows too big

c) you don't need random access to any elements

d) you want to be able to insert items in the middle of the list (such as a priority queue)

answer Feb 15, 2016 by Ajay Kumar Topno
The main benefits of using a LinkedList when you re-use existing iterators to insert and remove elements. These operations can then be done in O(1) by changing the list locally only. In an array list, the remainder of the array needs to be moved (i.e. copied).
...