Jump to content

Search data structure

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Vicarious (talk | contribs) at 19:06, 17 August 2009 (Creating page with some of the basics, could certainly use expansion.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

This is a comparison of data structures. All times are listed in big O notation

Insert Delete Search Find maximum Space usage
Array O(1) O(n) O(n) O(n) O(n)
Sorted Array O(n) O(n) O(log n) O(1) O(n)
Linked list O(1) O(1) O(n) O(n) O(n)
Sorted linked list O(1) O(1) O(n) O(n) O(n)
Binary search tree O(log n) O(log n) O(log n) O(log n) O(n)
Heap O(log n) O(1)† N/A O(1) O(n)
Hash table O(1) O(1) O(1) O(n) O(2n)

† Can only delete the max (or min in a min heap)

See also