Hey Everyone,
Post your solutions to the Apr 12 In-Class Exercise here.
Best, Chris
At the end of the input, if the current state we are in is the special final state, then we write 1 to the output tape. This takes 1 tape square which is within log space, L.
This will take at most log space to store the count of half the length of a correctly matched pairs.
n has at most n many states. We can keep track of which state a DFA is in with only log n many bits.n by tracking how many open parentheses we have found so far: incrementing when we encounter an open, and decrementing when we encounter a closed. In a string of size n matching parentheses, there will only be up to n/2 open parentheses, and in the worst case we can track them with log(n/2) bits.• DFA has K states where K is a constant: this requires a fixed amount of memory, which is in O(log(n))
• Parenthesis Language is in LOGSPACE, because all one needs to do is count parenthesis (adding or subtracting one at each symbol), and counting takes O(log(n))
• A stack is required to keep track of arbitrary symbols, and a stack can grow linearly, which is larger than LOGSPACE
#Since we have finitely many states, we will simulate the input on a TM with the same amount of states, and would only require an additional write space for the output. This can be done in constant space. #First we need to count the number of parenthesis which can be done in n/2 time, and keeping track of left vs right parenthesis which can be done in log space. #Since we have to keep track of the stack, there could be n many symbols to write on the work tape, which would be greater than logspace. Suppose we had a stack with log many symbols, this can be done in NL-space.
(Edited: 2017-04-12)3 .Since languages recognised by a PDA use stack, they grow in linear time. If a CFL is similar to PATH problem, we can say that it is in NL
(i) We could encode all the states of DFA in the input tape of the turing machine. We can output 1 if accept state is reached else 0. So it would take 1 tape square 1 is less than log space. (ii) The parathesis matching can be done as given: for every open paranthesis we increment the count and for closed paranthesis we decrement the count and when we finish parsing the input the count should be 0 if the parathesis match. So it would take atmost log(n/2) space. (iii)To check if a language is recognized by PDA, we use PATH algorithm which uses stack. The inputs put into a stack, the stack would grow linearly which is in NL.