Space–time tradeoff
   HOME

TheInfoList



OR:

A space–time trade-off or time–memory trade-off in
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includi ...
is a case where an
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
or
program Program, programme, programmer, or programming may refer to: Business and management * Program management, the process of managing several related projects * Time management * Program, a part of planning Arts and entertainment Audio * Progra ...
trades increased space usage with decreased time. Here, ''space'' refers to the data storage consumed in performing a given task (
RAM Ram, ram, or RAM may refer to: Animals * A male sheep * Ram cichlid, a freshwater tropical fish People * Ram (given name) * Ram (surname) * Ram (director) (Ramsubramaniam), an Indian Tamil film director * RAM (musician) (born 1974), Dutch * ...
, HDD, etc), and ''time'' refers to the time consumed in performing a given task ( computation time or
response time Response time may refer to: *The time lag between an electronic input and the output signal which depends upon the value of passive components used. * Responsiveness, how quickly an interactive system responds to user input * Response time (biolog ...
). The utility of a given space–time tradeoff is affected by related
fixed Fixed may refer to: * ''Fixed'' (EP), EP by Nine Inch Nails * ''Fixed'', an upcoming 2D adult animated film directed by Genndy Tartakovsky * Fixed (typeface), a collection of monospace bitmap fonts that is distributed with the X Window System * ...
and variable costs (of, e.g., CPU speed, storage space), and is subject to
diminishing returns In economics, diminishing returns are the decrease in marginal (incremental) output of a production process as the amount of a single factor of production is incrementally increased, holding all other factors of production equal ( ceteris parib ...
.


History

Biological usage of time–memory tradeoffs can be seen in the earlier stages of
animal behavior Ethology is the scientific study of animal behaviour, usually with a focus on behaviour under natural conditions, and viewing behaviour as an evolutionarily adaptive trait. Behaviourism as a term also describes the scientific and objectiv ...
. Using stored knowledge or encoding stimuli reactions as "instincts" in the DNA avoids the need for "calculation" in time-critical situations. More specific to computers, look-up tables have been implemented since the very earliest operating systems. In 1980
Martin Hellman Martin Edward Hellman (born October 2, 1945) is an American cryptologist and mathematician, best known for his involvement with public key cryptography in cooperation with Whitfield Diffie and Ralph Merkle. Hellman is a longtime contributor to ...
first proposed using a time–memory tradeoff for cryptanalysis.


Types of tradeoff


Lookup tables vs. recalculation

A common situation is an algorithm involving a lookup table: an implementation can include the entire table, which reduces computing time, but increases the amount of memory needed, or it can compute table entries as needed, increasing computing time, but reducing memory requirements.


Compressed vs. uncompressed data

A space–time tradeoff can be applied to the problem of data storage. If data is stored uncompressed, it takes more space but access takes less time than if the data were stored compressed (since compressing the data reduces the amount of space it takes, but it takes time to run the
decompression algorithm There are several categories of decompression equipment used to help divers decompress, which is the process required to allow divers to return to the surface safely after spending time underwater at higher ambient pressures. Decompression o ...
). Depending on the particular instance of the problem, either way is practical. There are also rare instances where it is possible to directly work with compressed data, such as in the case of compressed bitmap indices, where it is faster to work with compression than without compression.


Re-rendering vs. stored images

Storing only the SVG source of a
vector image Vector graphics is a form of computer graphics in which visual images are created directly from geometric shapes defined on a Cartesian plane, such as points, lines, curves and polygons. The associated mechanisms may include vector display a ...
and rendering it as a
bitmap image In computing, a bitmap is a mapping from some domain (for example, a range of integers) to bits. It is also called a bit array or bitmap index. As a noun, the term "bitmap" is very often used to refer to a particular bitmapping application: ...
every time the page is requested would be trading time for space; more time used, but less space. Rendering the image when the page is changed and storing the rendered images would be trading space for time; more space used, but less time. This technique is more generally known as caching.


Smaller code vs. loop unrolling

Larger code size can be traded for higher program speed when applying
loop unrolling Loop unrolling, also known as loop unwinding, is a loop transformation technique that attempts to optimize a program's execution speed at the expense of its binary size, which is an approach known as space–time tradeoff. The transformation ...
. This technique makes the code longer for each iteration of a loop, but saves the computation time required for jumping back to the beginning of the loop at the end of each iteration.


Other examples

Algorithms that also make use of space–time tradeoffs include: *
Baby-step giant-step In group theory, a branch of mathematics, the baby-step giant-step is a meet-in-the-middle algorithm for computing the discrete logarithm or order of an element in a finite abelian group by Daniel Shanks. The discrete log problem is of fundamenta ...
algorithm for calculating discrete logarithms * Rainbow tables in cryptography, where the adversary is trying to do better than the exponential time required for a
brute-force attack In cryptography, a brute-force attack consists of an attacker submitting many passwords or passphrases with the hope of eventually guessing correctly. The attacker systematically checks all possible passwords and passphrases until the correc ...
. Rainbow tables use partially precomputed values in the hash space of a
cryptographic hash function A cryptographic hash function (CHF) is a hash algorithm (a map of an arbitrary binary string to a binary string with fixed size of n bits) that has special properties desirable for cryptography: * the probability of a particular n-bit output re ...
to crack passwords in minutes instead of weeks. Decreasing the size of the rainbow table increases the time required to iterate over the hash space. * The meet-in-the-middle attack uses a space–time tradeoff to find the
cryptographic key A key in cryptography is a piece of information, usually a string of numbers or letters that are stored in a file, which, when processed through a cryptographic algorithm, can encode or decode cryptographic data. Based on the used method, the key ...
in only 2^ encryptions (and O(2^n) space) versus the expected 2^ encryptions (but only O(1) space) of the naive attack. *
Dynamic programming Dynamic programming is both a mathematical optimization method and a computer programming method. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, from aerospace engineering to economics. ...
, where the time complexity of a problem can be reduced significantly by using more memory.


See also

* * * * *


References


External links


Philippe Oechslin: Making a Faster Cryptanalytic Time-Memory Trade-Off.

Once Upon a Time-Memory Tradeoff.
{{DEFAULTSORT:Space-time tradeoff Software optimization