Skip to content
Snippets Groups Projects
Commit 951f4821 authored by Martin Mareš's avatar Martin Mareš
Browse files

Preliminaries: Technically speaking, hash tables support order operations

parent 1e80e26d
Branches
No related tags found
No related merge requests found
......@@ -112,7 +112,8 @@ $\opdf{Succ}(x)$ & Return the successor of $x\in{\cal U}$ --- the smallest
$\opdf{Pred}(x)$ & Similarly, the predecessor of~$x$ is the largest element
smaller than~$x$. \cr
}
Except for hash tables, all our implementations of sets can support order operations:
All our implementations of sets can support order operations,
but their time complexity varies:
$$\vbox{\halign{
#\hfil\qquad&&$#$\hfil~~\cr
& \alg{Min}/\alg{Max} & \alg{Pred}/\alg{Succ} \cr
......@@ -121,6 +122,7 @@ Linked list & \O(n) & \O(n) \cr
Array & \O(n) & \O(n) \cr
Sorted array & \O(1) & \O(\log n) \cr
Binary search tree & \O(\log n) & \O(\log n) \cr
Hash table & \O(n) & \O(n) \cr
}}$$
A~sequence can be sorted by $n$~calls to \alg{Insert}, one \alg{Min}, and $n$~calls to \alg{Succ}.
If the elements can be only compared, the standard lower bound for comparison-based sorting
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment