Hw №2, Theory of Computing Павел Захаров Task 1. For each of the signs ⊆, ⊇ tell whether they can be placed instead of ? in the expression TIME(𝑛2 ) ? SPACE(𝑛2 log 𝑛) Provide the proof. Solution. It’s clear that TIME(𝑛2 ) ⊆ SPACE(𝑛2 ) cause if we visit 𝑂(𝑛2 ) cells it takes 𝑂(𝑛2 ) time as well. But dew to Space Hierarchy Theorem we know that SPACE(𝑛2 ) ( SPACE(𝑛2 log 𝑛) (cause 𝑛2 = 𝑜(𝑛2 log 𝑛)). So: TIME(𝑛2 ) ⊆ SPACE(𝑛2 ) ⊂ SPACE(𝑛2 log 𝑛) and that’s why we can only place ⊆ instead of ? in given expression. 1 Task 2. The problem SUBSEQUENCE. Instance: binary words u, v. Question: Is u a subsequence of v? (I.e. u can be obtained from v by deleting some symbols.) Prove that SUBSEQUENCE is in P. Solution. Let’s describe polynomial algorithm, solving SUBSEQUENCE problem on TM. Let the first head points at the first letter of 𝑣 and the second one points at the start of 𝑢. We gonna move them together for 1 letter to the right each turn and compare appropriate letters. If letters under the heads are not equal, then we remove selected one in word 𝑣. If we reach the end of the word 𝑢 then answer is «yes, 𝑢 is subsequence of 𝑣» and the opposite one if we reach 𝑣’s end firstly. Cause if we reach the end of 𝑢, then we obtain a different position in 𝑣 for each one letter is equal to some letter in 𝑢 in correct order. If we have some subsequence we are able to rechoose its first symbol such it would be the lefter one. Then rechoose second sybmbol such that there is at least one symbol, equal to the first letter in subsequence, and so on. After all we have the same subsequence as we build in our solution – first in lexical order. 2