What is the difference between linked list and Arrays?

Answer

linked list consists of data nodes, each pointing to the next in the list. An array consists of contiguous chunks memory of predetermined size.

Linked lists are quite flexible. They can grow to any size -- up to resource limits -- and each node can be a different size. Memory allocation for a node is done as needed, usually when a new node is added.

Linked lists can be circular, or doubly-linked (pointers forward and backward), and new nodes can be inserted anywhere in the chain.

The greatest downside to linked lists is sequential access: to find any node in memory, each previous node must be examined and the pointers followed. Linked lists are also more complex to program and manage.

Arrays are fixed in size, so resources must be anticipated and consumed in advance. Each element is the same size and must contain the same data type. But access to a particular element is very fast, because its location in memory can be determined mathematically and accessed directly (offset from start of array = subscript * element size).

Note that modern languages -- especially OO languages such as C++ and Java -- blur this distinction by providing classes which offer the best of both worlds. Arrays can grow; linked list complexity is hidden from the programmer; hash tables (special arrays, really) allow for rapid indexing of arbitrary data. But under the hood, each complex data type is implemented using primitives such as arrays and linked lists

Improve Answer View existing comments for "What is the difference between linked list and Arrays?" Watch Question

First answer by ID3418854922. Last edit by ID3418854922. Question popularity: 12 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Terminology > What is the difference between linked list and Arrays?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
What is linkedlist?  Waht is linked list?  What is a linked list?  Linked list and arrays?  Arrays and linked list?  Arrays vs linked lists?  Difference array linked list?  Diff between arrays and list?  Between arrays and linked list?  Arrays and linked list difference?  Difference arrays and linked list?  Difference between and linked list?  Difference between arrays and list?  Difference of array and linked list?  Difference btn array and linked list?  Difference bw arrays and linked lists?  Difference between arrays linked list?  Difference between arrays linked lists?  Advantages of linked lists over arrays?  How do you detect a loop in linked list?