Computer Terminology
Math and Arithmetic
C Programming

How linked lsts can be usd to represent long integers?

User Avatar
Wiki User
July 10, 2007 11:41AM

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