1 / 19

Space Complexity

Space Complexity. Guy Feigenblat Based on lecture by Dr. Ely Porat Complexity course Computer science department , Bar-Ilan university December 2008. Introduction. What is the space complexity of algorithm that verifies the sequences: A 1 = {a*b*} O(1)

connie
Download Presentation

Space Complexity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Space Complexity Guy Feigenblat Based on lecture by Dr. Ely Porat Complexity course Computer science department , Bar-Ilan university December 2008

  2. Introduction What is the space complexity of algorithm that verifies the sequences: A1 = {a*b*} O(1) A2 = {anbn | n > 0} O(log n)

  3. Space Complexity of Algorithm Q O(1) Work S(n) Pointers log(n) + log (S(n)) O(S(n))

  4. Definitions DSAPCE (S(n)) = {L| M, s.t. M is a deterministic Turing machine using space O(S(n)) and L=L(M) } NSAPCE (S(n)) = {L| M, s.t. M is a non-deterministic Turing machine using space O(S(n))) and L=L(M) } L = DSAPCE(O(logn)) NL = NSAPCE(O(logn)) L NL

  5. DefinitionS S-T-Conn = {(G,s,t) | G is a directed Graph, there is a path from s to t } Claim: S-T-Conn NL

  6. S-T-Conn NL Observation - If there exist a path, the “oracle” will find it. Attempt 1: Get from the “Oracle” the path and verify it. To much space – O( |V|log|V|) !!! Attempt 2: Start from an arbitrary edge (s,x1) Get from the oracle the next edge (x1,x2) , check it exist & dump s. Continue till reaching (xn,t). Total – 2log|V| - keeping at most 2 vertices at each time.

  7. Theorem L P Each Turing machine, in L, works with O(logn) space. Namely, for some constant C, it uses Clogn bits. Since Turing machine, in L, is deterministic we will only perform each state once, otherwise going into loop. The total possible states is therefore O(nc).

  8. Theorem NL NP If there exist a Turing machine solving the problem in O(log n) space then there exist a set of states bounded by O (nc). Recall that we need to return {0,1}. We count the number of steps the algorithm perform, if it exceeds O (nc) return 0. else return the algorithm output.

  9. NL-Complete (NLC) Logarithmic space reduction

  10. Problem ?! The reduction concatenate 2 machines. Is it allowed ? Using clogn memory, machine can produce input in the size of nc.

  11. Solution Notice that the output stream of M is the input stream of . Pre-process: M run until it writes the first variable on its input stream. When needs to read another input, it calls M and runs it till M writes the next output variable.

  12. Claim: S-T-Conn NLC We already proved א' condition. Still need to prove ב' condition

  13. Intuition We need to build a graph, as an input to S-T-Conn. We will build it base on the possible transposition (configurations) of each L’. Since L’ NL, The transposition graph size will be at most: 2clogn = nc = |V|

  14. Proof Clearly, the space used in the reduction is O(logn) Print to output stream

  15. Conclusion: NL P S-T-Conn P Why ?? BFS / DFS S-T-Conn NLC Was proven NL P We can solve any problem in NL using S-T-Conn and S-T-Conn can be solved Polynomial time.

  16. Claim: NL DSPACE (log2n) Enough to show S-T-Conn DSPACE (log2n) Consider the below algorithm: Is There a path between vertexes s,t in length less then d ?

  17. Explanation • Clearly the algorithm is deterministic • While the algorithm’s running time is exponential, it only uses O(log2n) bits. • In each step, we have, maximum, O(logn) vertices, each in size of O(logn) bits Thus, the total space consumption is O(log2n) bits.

  18. Definition Co-NL = Clearly, S-T-Conn Co-NL It is known that S-T-Conn Co-NLC Does Co-NL = NL ? S-T-Conn NL Co-NL NL NL=Co-NL Enough to show

  19. Theorem: NL=Co-NL You will see in the Tirgul N is the group of vertexes in the connected component of S . This program shows that Non-S-T-Conn is also in NL: S-T-Conn NL From definition, we now get: S-T-Conn Co-NL Concluding that NL=Co-NL

More Related