Technopedia

The technologist’s encyclopedia

Search and Data Structures

Search and data structures study how to organize data so that algorithms can access it cheaply. They are relevant whenever a program must store, retrieve, or update large collections of items: from a single in-memory hash table to a distributed database serving millions of queries per second.

Utility

Details

The five classes partition search problems by the access pattern that defines the query. Each builds on the previous: flat structures give O(1)O(1) positional access with no ordering; hierarchical structures add ordering for O(log⁡n)O(\log n) key access; text structures exploit the alphabet to match patterns; relational structures combine multiple key dimensions with predicates; graph structures generalize to arbitrary connectivity.

History

Classes

SubtopicAccess patternSearchInsert / DeleteSpace
ListsPositional (index into a sequence)O(1) by index, O(n) by valueO(1) amortized (vector)O(n)
Key-Value StoresKey-based (hash or ordered)O(1) expected / O(log n)O(1) / O(log n)O(n)
Text SearchPattern / substringO(n+m) to O(n log n)O(n)O(n) to O(n log n)
Database TheoryRelational (predicate over tuples)O(log n) (indexed)O(log n)O(n) + index overhead
GraphsConnectivity (adjacency)O(n+m) traversalO(1) per edgeO(n+m)

Authoritative sources