Computational Model - WilfullMurder/DataStructures-Java GitHub Wiki
Throughout this repo (and subsequent wiki), we analyse the theoretical running times of operations on the data structures we have been studying. In order to do this precisely, we need a Mathematical model of computation. Fot this, we chose to use the w-bit word-RAM (Random Access Machine) model. In this model, we have access to a Random Access Memory consisting of cells, each storing a w-bit word. This implies that a memory cell can represent, for example, any integer, x, where x∈{0,...,2w-1}.
In the word-RAM model, basic operations on words take constant time. Including arithematic operators (+,-,*,/,%), comparisons (<,>,=,≤,≥), and bitwise boolean operations (bitwise-AND, OR, and XOR).
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, w is a very important parameter of this model. The only assumption to be made about w is the lower-bound w ≥ logn, where 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 R occupies one word of memory. (In reality, we are storing references to objects of type T, and these references occupy only one word of memory.)
The logic behind the choice in computational model is that the w-bit word-RAM model is a fairly close match for the (32-bit) Java Virtual Machine (JVM) when w = 32. The data strucures studied do not implement any special tricks that are not implementable on the JVM.