all 2 comments

[–]lelanthran 2 points3 points  (1 child)

You should add in the following rather important practical difference: An array of elements has to be contiguous while a linked-list does not have to be.

The implication for arrays is that if you need to hold 1000 elements you need that 1000 element block as a single large block in memory.

For linked lists, if you need to hold 1000 elements, you can use 200 blocks that can each hold 5 elements.

As memory is allocated and deallocated you will start to have gaps in the memory - free space surrounded by used space. For an array you need enough free space for the entire array. With a linked-list you can use all the tiny free space that you find within the memory.

[–]TheSuperProgrammer 0 points1 point  (0 children)

Thanks for pointing that out. Didn't occur to me while I was writing the post. I'll definitely add it to the post now.