Array Vs. Linked List

Posted by Onorio Catenacci on Stack Overflow See other posts from Stack Overflow or by Onorio Catenacci
Published on 2008-10-03T13:35:53Z Indexed on 2010/04/10 1:03 UTC
Read the original article Hit count: 433

I apologize--this question may be a bit open-ended but I think there are probably definite, quantifiable answers to it so I'll post it anyway.

A person I know is trying to learn C++ and software development (+1 to him) and he asked me why someone would want to use a linked list in preference to an array. Coding a linked list is, no doubt, a bit more work than using an array and he wondered what would justify the additional effort.

I gave him the answer I know: insertion of new elements is trivial in linked list but it's a major chore in an array. But then I got to thinking about it a bit more. Besides the ease of insertion of a new element into a linked list are there other advantages to using a linked list to store a set of data vs. storing it in an array?

As I said, I'm not meaning to start a long and drawn-out discussion. I'm just looking for other reasons that a developer might prefer a linked list to an array.

© Stack Overflow or respective owner

Related posts about data-structures

Related posts about comparison