| Compactness | Speed of Access | Handling of Empty Elements | |||
|---|---|---|---|---|---|
| Array | Poor | Unless the size is know in advance and the majority of elements are filled, when it becomes very good. | Very fast | Constant | Space must be allocated with an indication of "emptiness". |
| Linked List | Good | There is some overhead for additional references to maintain the list, but unused elements do not need to be stored if all items are consecutive. | Slow | Average access proportional to number of elements (including empty ones) | Elements must be allocate to represent empty items, and addition or removal of items in the list affects the index of all following elements. |
| Tree | Reasonable | There is some overhead for additional references to maintain the list, and in Java, there is a need to build an entire object for each key of each element. | Fast | Average access proportional to Log2(number of elements) | Empty elements do not need to be represented. |
| Sparse Array | Very good | There is some overhead for the lookup table of valid references. | Fast | Average access proportional to Log2(number of elements) | Empty elements do not need to be represented. |
.
This technical paper was written by David Clarke of Dragon Thoughts Ltd and is Copyright David Clarke © 2002