1.4 The Model of Computation

In this book, we will analyze the theoretical running times of operations on the data structures we study. To do this precisely, we need a mathematical model of computation. For this, we use the $ \ensuremath{\ensuremath{\mathit{w}}}$-bit word-RAM model. RAM stands for Random Access Machine. In this model, we have access to a random access memory consisting of cells, each of which stores a $ \ensuremath{\ensuremath{\mathit{w}}}$-bit word. This implies that a memory cell can represent, for example, any integer in the set $ \{0,\ldots,2^{\ensuremath{\ensuremath{\ensuremath{\mathit{w}}}}}-1\}$.

In the word-RAM model, basic operations on words take constant time. This includes arithmetic operations ($ +$, $ -$, $ \cdot $, $ /$, $ \bmod $), comparisons ($ <$, $ >$, $ =$, $ \le$, $ \ge$), and bitwise boolean operations (bitwise-AND, OR, and exclusive-OR).

Any cell can be read or written in constant time. A computer's memory is managed by a memory management system from which we can allocate or deallocate a block of memory of any size we would like. Allocating a block of memory of size $ k$ takes $ O(k)$ time and returns a reference (a pointer) to the newly-allocated memory block. This reference is small enough to be represented by a single word.

The word-size $ \ensuremath{\ensuremath{\mathit{w}}}$ is a very important parameter of this model. The only assumption we will make about $ \ensuremath{\ensuremath{\mathit{w}}}$ is the lower-bound $ \ensuremath{\ensuremath{\ensuremath{\mathit{w}}}} \ge \log \ensuremath{\ensuremath{\ensuremath{\mathit{n}}}}$, where $ \ensuremath{\ensuremath{\mathit{n}}}$ is the number of elements stored in any of our data structures. This is a fairly modest assumption, since otherwise a word is not even big enough to count the number of elements stored in the data structure.

Space is measured in words, so that when we talk about the amount of space used by a data structure, we are referring to the number of words of memory used by the structure. All of our data structures store values of a generic type T, and we assume an element of type T occupies one word of memory.

The data structures presented in this book don't use any special tricks that are not implementable

opendatastructures.org