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.
2006-09-12 19:03:11
·
answer #1
·
answered by Peter_Jackson_Fan 4
·
1⤊
0⤋
Array Linked List
2016-11-07 08:16:50
·
answer #2
·
answered by Erika 4
·
0⤊
0⤋
The Basic Diffrence between Liked list is that the
1. Array have continius memory location while linked list are not continues in memory.
2. You must know the Size eg dimention of array while declaring but liked list dosen't matter what the size of lianked list is.
3. Linked list strores a bit extra memory due to pointer at the last element. While Array Won't
4. Linked list cannot be accessed directoly to any element you have to move sequentioly.
5. Deleting a node on linked list quite easy while it is difficult in Array to delete a Element.
6. Inserting a node on linked list quite easy while it is difficult in Array to Insert a Element.
Though it is quite easy but also quite confusing, isn't it?
Good luck, Happy Programming!
2006-09-12 19:44:16
·
answer #3
·
answered by Piyush 2
·
0⤊
0⤋
A linked list does not allow random access, while an array does.
With a linked list, you have to traverse from one element to the next, searching for what you want; an array you can index directly into the element you want, assuming you know where the information you want is.
In the future, instead of Yahoo Answers, you may want to try Wikipedia directly... :)
2006-09-12 19:05:07
·
answer #4
·
answered by Kimberley Mc 3
·
0⤊
0⤋