Thursday, May 13, 2010

the difference between a linked list and an array

A linked list consists of data nodes, each pointing to the next in the list.They can grow to any size.each node can be a different size. Memory allocation for a node is done as needed.Linked lists can be circular, or doubly-linked (pointers forward and backward), and new nodes can be inserted anywhere in the chain.

downside: sequential access. Finding a node takes linear time. O(n)

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.Finding a node is fast, can be calculated mathmetically

No comments:

Post a Comment