HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

Is an integer variable constant or logarithmic space?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
spaceconstantlogarithmicvariableinteger

Problem

My lecturer says that a variable takes up one memory position in RAM. This is the slide in question:

But CLRS (Introduction to Algorithms by Cormen, end of page 23) says an integer is represented by $c\ lg\ n$.

Are both statements true? How can that be?

Solution

The random-access machine is a common model of computation, which is the model of choice when analyzing algorithms. In this model, memory consists of words of length $\Theta(\log n)$ bits, where $n$ is the length of the input (in bits). Therefore both your lecturer and CLRS are right.

Context

StackExchange Computer Science Q#139090, answer score: 21

Revisions (0)

No revisions yet.