# 1.7: List of Data Structures

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\avec}{\mathbf a}$$ $$\newcommand{\bvec}{\mathbf b}$$ $$\newcommand{\cvec}{\mathbf c}$$ $$\newcommand{\dvec}{\mathbf d}$$ $$\newcommand{\dtil}{\widetilde{\mathbf d}}$$ $$\newcommand{\evec}{\mathbf e}$$ $$\newcommand{\fvec}{\mathbf f}$$ $$\newcommand{\nvec}{\mathbf n}$$ $$\newcommand{\pvec}{\mathbf p}$$ $$\newcommand{\qvec}{\mathbf q}$$ $$\newcommand{\svec}{\mathbf s}$$ $$\newcommand{\tvec}{\mathbf t}$$ $$\newcommand{\uvec}{\mathbf u}$$ $$\newcommand{\vvec}{\mathbf v}$$ $$\newcommand{\wvec}{\mathbf w}$$ $$\newcommand{\xvec}{\mathbf x}$$ $$\newcommand{\yvec}{\mathbf y}$$ $$\newcommand{\zvec}{\mathbf z}$$ $$\newcommand{\rvec}{\mathbf r}$$ $$\newcommand{\mvec}{\mathbf m}$$ $$\newcommand{\zerovec}{\mathbf 0}$$ $$\newcommand{\onevec}{\mathbf 1}$$ $$\newcommand{\real}{\mathbb R}$$ $$\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}$$ $$\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}$$ $$\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}$$ $$\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}$$ $$\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}$$ $$\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}$$ $$\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}$$ $$\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}$$ $$\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}$$ $$\newcommand{\laspan}[1]{\text{Span}\{#1\}}$$ $$\newcommand{\bcal}{\cal B}$$ $$\newcommand{\ccal}{\cal C}$$ $$\newcommand{\scal}{\cal S}$$ $$\newcommand{\wcal}{\cal W}$$ $$\newcommand{\ecal}{\cal E}$$ $$\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}$$ $$\newcommand{\gray}[1]{\color{gray}{#1}}$$ $$\newcommand{\lgray}[1]{\color{lightgray}{#1}}$$ $$\newcommand{\rank}{\operatorname{rank}}$$ $$\newcommand{\row}{\text{Row}}$$ $$\newcommand{\col}{\text{Col}}$$ $$\renewcommand{\row}{\text{Row}}$$ $$\newcommand{\nul}{\text{Nul}}$$ $$\newcommand{\var}{\text{Var}}$$ $$\newcommand{\corr}{\text{corr}}$$ $$\newcommand{\len}[1]{\left|#1\right|}$$ $$\newcommand{\bbar}{\overline{\bvec}}$$ $$\newcommand{\bhat}{\widehat{\bvec}}$$ $$\newcommand{\bperp}{\bvec^\perp}$$ $$\newcommand{\xhat}{\widehat{\xvec}}$$ $$\newcommand{\vhat}{\widehat{\vvec}}$$ $$\newcommand{\uhat}{\widehat{\uvec}}$$ $$\newcommand{\what}{\widehat{\wvec}}$$ $$\newcommand{\Sighat}{\widehat{\Sigma}}$$ $$\newcommand{\lt}{<}$$ $$\newcommand{\gt}{>}$$ $$\newcommand{\amp}{&}$$ $$\definecolor{fillinmathshade}{gray}{0.9}$$

Tables $$\PageIndex{1}$$ and $$\PageIndex{2}$$ summarize the performance of data structures in this book that implement each of the interfaces, List, USet, and SSet, described in Section 1.2. Figure $$\PageIndex{1}$$ shows the dependencies between various chapters in this book. A dashed arrow indicates only a weak dependency, in which only a small part of the chapter depends on a previous chapter or only the main results of the previous chapter.

Table $$\PageIndex{1}$$: Summary of List and USet implementations.

$$\texttt{List}$$ implementations

$$\mathtt{get(i)}/\mathtt{set(i,x)}$$ $$\mathtt{add(i,x)}/\mathtt{remove(i)}$$
$$\texttt{ArrayStack}$$ $$O(1)$$ $$O(1+\mathtt{n}-\mathtt{i})$$A § 2.1
$$\texttt{ArrayDeque}$$ $$O(1)$$ $$O(1+\min\{\mathtt{i},\mathtt{n}-\mathtt{i}\})$$A § 2.4
$$\texttt{DualArrayDeque}$$ $$O(1)$$ $$O(1+\min\{\mathtt{i},\mathtt{n}-\mathtt{i}\})$$A § 2.5
$$\texttt{RootishArrayStack}$$ $$O(1)$$ $$O(1+\mathtt{n}-\mathtt{i})$$A § 2.6
$$\texttt{DLList}$$ $$O(1+\min\{\mathtt{i},\mathtt{n}-\mathtt{i}\})$$ $$O(1+\min\{\mathtt{i},\mathtt{n}-\mathtt{i}\})$$ § 3.2
$$\texttt{SEList}$$ $$O(1+\min\{\mathtt{i},\mathtt{n}-\mathtt{i}\}/\mathtt{b})$$ $$O(\mathtt{b}+\min\{\mathtt{i},\mathtt{n}-\mathtt{i}\}/\mathtt{b})$$A § 3.3
$$\texttt{SkiplistList}$$ $$O(\log \mathtt{n})$$E $$O(\log \mathtt{n})$$E § 4.3

$$\texttt{USet}$$ implementations

$$\mathtt{find(x)}$$ $$\mathtt{add(x)}/\mathtt{remove(x)}$$
A Denotes an amortized running time.
E Denotes an expected running time.
$$\texttt{ChainedHashTable}$$ $$O(1)$$E $$O(1)$$A,E § 5.1
$$\texttt{LinearHashTable}$$ $$O(1)$$E $$O(1)$$A,E § 5.2

Table $$\PageIndex{2}$$: Summary of SSet and priority Queue implementations.

$$\texttt{SSet}$$ implementations

$$\mathtt{find(x)}$$ $$\mathtt{add(x)}/\mathtt{remove(x)}$$
$$\texttt{SkiplistSSet}$$ $$O(\log \mathtt{n})$$E $$O(\log \mathtt{n})$$E § 4.2
$$\texttt{Treap}$$ $$O(\log \mathtt{n})$$E $$O(\log \mathtt{n})$$E § 7.2
$$\texttt{ScapegoatTree}$$ $$O(\log \mathtt{n})$$ $$O(\log \mathtt{n})$$A § 8.1
$$\texttt{RedBlackTree}$$ $$O(\log \mathtt{n})$$ $$O(\log \mathtt{n})$$ § 9.2
$$\texttt{BinaryTrie}$$I $$O(\mathtt{w})$$ $$O(\mathtt{w})$$ § 13.1
$$\texttt{XFastTrie}$$I $$O(\log \mathtt{w})$$A,E $$O(\mathtt{w})$$A,E § 13.2
$$\texttt{YFastTrie}$$I $$O(\log \mathtt{w})$$A,E $$O(\log \mathtt{w})$$A,E § 13.3
$$\texttt{BTree}$$ $$O(\log \mathtt{n})$$ $$O(B+\log \mathtt{n})$$A § 14.2
$$\texttt{BTree}$$X $$O(\log_B \mathtt{n})$$ $$O(\log_B \mathtt{n})$$ § 14.2

(Priority) $$\texttt{Queue}$$ implementations

$$\mathtt{findMin()}$$ $$\mathtt{add(x)}/\mathtt{remove()}$$
I This structure can only store $$\texttt{w}$$-bit integer data.
X This denotes the running time in the external-memory model; see Chapter 14.
$$\texttt{BinaryHeap}$$ $$O(1)$$ $$O(\log \mathtt{n})$$A § 10.1
$$\texttt{MeldableHeap}$$ $$O(1)$$ $$O(\log \mathtt{n})$$E § 10.2

This page titled 1.7: List of Data Structures is shared under a CC BY license and was authored, remixed, and/or curated by Pat Morin (Athabasca University Press) .