Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Space complexity

From Wikipedia, the free encyclopedia
Computer memory needed by an algorithm

Thespace complexity of analgorithm or adata structure is the amount of memory space required to solve an instance of thecomputational problem as a function of characteristics of the input. It is the memory required by an algorithm until it executes completely.[1] This includes the memory space used by its inputs, calledinput space, and any other (auxiliary) memory it uses during execution, which is calledauxiliary space.

Similar totime complexity, space complexity is often expressed asymptotically inbigO notation, such asO(n),{\displaystyle O(n),}O(nlogn),{\displaystyle O(n\log n),}O(nα),{\displaystyle O(n^{\alpha }),}O(2n),{\displaystyle O(2^{n}),} etc., wheren is a characteristic of the input influencing space complexity.

Space complexity classes

[edit]

Analogously to time complexity classesDTIME(f(n)) andNTIME(f(n)), the complexity classesDSPACE(f(n)) andNSPACE(f(n)) are the sets of languages that are decidable by deterministic (respectively, non-deterministic)Turing machines that useO(f(n)){\displaystyle O(f(n))} space. The complexity classesPSPACE andNPSPACE allowf{\displaystyle f} to be any polynomial, analogously toP andNP. That is,PSPACE=cZ+DSPACE(nc){\displaystyle {\mathsf {PSPACE}}=\bigcup _{c\in \mathbb {Z} ^{+}}{\mathsf {DSPACE}}(n^{c})}andNPSPACE=cZ+NSPACE(nc){\displaystyle {\mathsf {NPSPACE}}=\bigcup _{c\in \mathbb {Z} ^{+}}{\mathsf {NSPACE}}(n^{c})}

Relationships between classes

[edit]

Thespace hierarchy theorem states that, for allspace-constructible functionsf(n),{\displaystyle f(n),} there exists a problem that can be solved by a machine withf(n){\displaystyle f(n)} memory space, but cannot be solved by a machine with asymptotically less thanf(n){\displaystyle f(n)} space.

The following containments between complexity classes hold.[2]DTIME(f(n))DSPACE(f(n))NSPACE(f(n))DTIME(2O(f(n))){\displaystyle {\mathsf {DTIME}}(f(n))\subseteq {\mathsf {DSPACE}}(f(n))\subseteq {\mathsf {NSPACE}}(f(n))\subseteq {\mathsf {DTIME}}\left(2^{O(f(n))}\right)}

Furthermore,Savitch's theorem gives the reverse containment that iffΩ(log(n)),{\displaystyle f\in \Omega (\log(n)),}NSPACE(f(n))DSPACE((f(n))2).{\displaystyle {\mathsf {NSPACE}}(f(n))\subseteq {\mathsf {DSPACE}}\left((f(n))^{2}\right).}

As a direct corollary,PSPACE=NPSPACE.{\displaystyle {\mathsf {PSPACE}}={\mathsf {NPSPACE}}.} This result is surprising because it suggests that non-determinism can reduce the space necessary to solve a problem only by a small amount. In contrast, theexponential time hypothesis conjectures that for time complexity, there can be an exponential gap between deterministic and non-deterministic complexity.

TheImmerman–Szelepcsényi theorem states that, again forfΩ(log(n)),{\displaystyle f\in \Omega (\log(n)),}NSPACE(f(n)){\displaystyle {\mathsf {NSPACE}}(f(n))} is closed under complementation. This shows another qualitative difference between time and space complexity classes, as nondeterministic time complexity classes are not believed to be closed under complementation; for instance, it is conjectured that NP ≠co-NP.[3][4]

LOGSPACE

[edit]
Main article:L (complexity)

L or LOGSPACE is the set of problems that can be solved by a deterministic Turing machine using onlyO(logn){\displaystyle O(\log n)} memory space with regards to input size. Even a single counter that can index the entiren{\displaystyle n}-bit input requireslogn{\displaystyle \log n} space, so LOGSPACE algorithms can maintain only a constant number of counters or other variables of similar bit complexity.

LOGSPACE and other sub-linear space complexity is useful when processing large data that cannot fit into a computer'sRAM. They are related toStreaming algorithms, but only restrict how much memory can be used, while streaming algorithms have further constraints on how the input is fed into the algorithm.This class also sees use in the field ofpseudorandomness andderandomization, where researchers consider the open problem of whetherL =RL.[5][6]

The corresponding nondeterministic space complexity class isNL.

Auxiliary space complexity

[edit]

The termauxiliary space refers to space other than that consumed by the input.Auxiliary space complexity could be formally defined in terms of aTuring machine with a separateinput tape which cannot be written to, only read, and a conventional working tape which can be written to.The auxiliary space complexity is then defined (and analyzed) via the working tape.For example, consider thedepth-first search of abalanced binary tree withn{\displaystyle n} nodes: its auxiliary space complexity isΘ(logn).{\displaystyle \Theta (\log n).}

See also

[edit]

References

[edit]
  1. ^Kuo, Way; Zuo, Ming J. (2003),Optimal Reliability Modeling: Principles and Applications, John Wiley & Sons, p. 62,ISBN 9780471275459
  2. ^Arora, Sanjeev; Barak, Boaz (2007),Computational Complexity : A Modern Approach(PDF) (draft ed.), p. 76,ISBN 9780511804090
  3. ^Immerman, Neil (1988),"Nondeterministic space is closed under complementation"(PDF),SIAM Journal on Computing,17 (5):935–938,doi:10.1137/0217058,MR 0961049
  4. ^Szelepcsényi, Róbert (1987), "The method of forcing for nondeterministic automata",Bulletin of the EATCS,33:96–100
  5. ^Nisan, Noam (1992), "RL ⊆ SC",Proceedings of the 24th ACM Symposium on Theory of computing (STOC '92), Victoria, British Columbia, Canada, pp. 619–623,doi:10.1145/129712.129772,ISBN 0-89791-511-9,S2CID 11651375{{citation}}: CS1 maint: location missing publisher (link).
  6. ^Reingold, Omer;Trevisan, Luca;Vadhan, Salil (2006),"Pseudorandom walks on regular digraphs and the RL vs. L problem"(PDF),STOC'06: Proceedings of the 38th Annual ACM Symposium on Theory of Computing, New York: ACM, pp. 457–466,doi:10.1145/1132516.1132583,ISBN 1-59593-134-1,MR 2277171,S2CID 17360260
Retrieved from "https://en.wikipedia.org/w/index.php?title=Space_complexity&oldid=1323512846"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp