Comparison of data structures


This is a comparison of the performance of notable data structures, as measured by the complexity of their logical operations. For a more comprehensive listing of data structures, see List of data structures.
The comparisons in this article are organized by abstract data type. As a single concrete data structure may be used to implement many abstract data types, some data structures may appear in multiple comparisons.

Lists

A list or sequence is an abstract data type that represents a finite number of ordered values, where the same value may occur more than once. Lists generally support the following operations:peek: access the element at a given index.insert: insert a new element at a given index. When the index is zero, this is called prepending; when the index is the last index in the list it is called appending.delete: remove the element at a given index.

Maps

Maps store a collection of pairs, such that each possible key appears at most once in the collection. They generally support three operations:Insert: add a new pair to the collection, mapping the key to its new value. Any existing mapping is overwritten. The arguments to this operation are the key and the value.Remove: remove a pair from the collection, unmapping a given key from its value. The argument to this operation is the key.Lookup: find the value that is bound to a given key. The argument to this operation is the key, and the value is returned from the operation.
Unless otherwise noted, all data structures in this table require O space.

Integer keys

Some map data structures offer superior performance in the case of integer keys. In the following table, let be the number of bits in the keys.

Priority queues

A priority queue is an abstract data-type similar to a regular queue or stack. Each element in a priority queue has an associated priority. In a priority queue, elements with high priority are served before elements with low priority. Priority queues support the following operations:insert: add an element to the queue with an associated priority.find-max: return the element from the queue that has the highest priority.delete-max: remove the element from the queue that has the highest priority.
Priority queues are frequently implemented using heaps.

Heaps

A heap is a tree-based data structure which satisfies the : for any given node C, if P is a parent node of C, then the key of P is greater than or equal to the key of C.
In addition to the operations of an abstract priority queue, the following table lists the complexity of two additional logical operations:increase-key: updating a key.meld: joining two heaps to form a valid new heap containing all the elements of both, destroying the original heaps.