+ All Categories
Home > Documents > Space Complexity

Space Complexity

Date post: 07-Feb-2016
Category:
Upload: connie
View: 44 times
Download: 6 times
Share this document with a friend
Description:
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) - PowerPoint PPT Presentation
19
Space Complexity Guy Feigenblat Based on lecture by Dr. Ely Porat Complexity course Computer science department , Bar-Ilan university December 2008
Transcript
Page 1: Space Complexity

Space Complexity

Guy Feigenblat

Based on lecture by Dr. Ely Porat Complexity course Computer science department , Bar-Ilan universityDecember 2008

Page 2: Space Complexity

Introduction

What is the space complexity of algorithm that verifies the sequences:

A1 = {a*b*} O(1)

A2 = {anbn | n > 0}O(log n)

Page 3: Space Complexity

Space Complexity of Algorithm

Q O(1)Work S(n)Pointers log(n) + log (S(n))

O(S(n))

Page 4: Space Complexity

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

Page 5: Space Complexity

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

Page 6: Space Complexity

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.

Page 7: Space Complexity

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).

Page 8: Space Complexity

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.

Theorem NL NP

Page 9: Space Complexity

NL-Complete (NLC)

Logarithmic space reduction

Page 10: Space Complexity

Problem ?!

The reduction concatenate 2 machines. Is it allowed ? Using clogn memory, machine can produce

input in the size of nc.

Page 11: Space Complexity

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.

M~

M~

Page 12: Space Complexity

Claim: S-T-Conn NLC

We already proved א' condition. Still need to prove ב' condition

Page 13: Space Complexity

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|

Page 14: Space Complexity

Proof

Print to output stream

Clearly, the space used in the reduction

is O(logn)

Page 15: Space Complexity

Conclusion: NL P

S-T-Conn P Why ??

BFS / DFS

S-T-Conn NLCWas proven

NL P

We can solve any problem in NL using S-T-Conn and S-T-Conn can be solved Polynomial time.

Page 16: Space Complexity

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 ?

Page 17: Space Complexity

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.

Page 18: Space Complexity

Definition

Co-NL =

Clearly, S-T-Conn Co-NLIt is known that S-T-Conn Co-NLC

Does Co-NL = NL ?

S-T-Conn NL Co-NL NL NL=Co-NL

}|{ NLLL

Enough to show

Page 19: Space Complexity

Theorem: NL=Co-NL

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

You will see in the Tirgul


Recommended