2011-05-16

Practice final problem 7 .

'''Originally Posted By: ngswamy'''

Prove that n^2 is a proper complexity function: <br><br>We need to satisfy two property:<br>* f is nondecreasing<br>* there is a deterministic TM M that when started with x on the input tape, runs for t=O(|x|+f(|x|)) steps, uses at most O(f(|x|)) space, and outputs to an output tape the string I^f(|x|)<br><br>We know that n^2 is a non-decreasing function<br><br>For the second property, create a machine M, which takes input n and outputs n^2 using n^2 space on the tape and takes O(|n| + f(|n|)) steps:The machine works as follows:<br><br>1.Replace the first two inputs of n with A (if the input length n is 1, then 1 will be replaced with A, and when it tries to replace the next A it will reach a space in which it will move on to replace the A back with 1 and then accepts). <br>2. Then read each input from the original input moving right from A on the tape. If you read an A or a 1 on the original input, move to the left of the first A and when you read an empty spot, mark down a one. (As you read each symbol from the original input you should replace it with A or 1, depending on whether it is an A or a 1 so that you know where you left off.)<br>3. After that, move to the right most A and if you read a 1, replace it with an A and repeat the second step. Keep doing this until you reach a empty space on the right side of the tape.<br>4. Once you reach the empty space on the right side of the tape, go back and replace any A with a 1. Then move to the right until you read an empty space, and then accept. <br><br>State the deterministic time hierarchy theorem as presented in class:<br>If f(n)>=n is a proper complexity function, then the class TIME(f(n)) is strictly contained in TIME(f(2n+1)^3). <br><br>Richelle Limun<br>James Yu<br>Cameron Taslim<br>Nanda Guruswamy

'''Originally Posted By: ngswamy''' Prove that n^2 is a proper complexity function: <br><br>We need to satisfy two property:<br>* f is nondecreasing<br>* there is a deterministic TM M that when started with x on the input tape, runs for t=O(|x|+f(|x|)) steps, uses at most O(f(|x|)) space, and outputs to an output tape the string I^f(|x|)<br><br>We know that n^2 is a non-decreasing function<br><br>For the second property, create a machine M, which takes input n and outputs n^2 using n^2 space on the tape and takes O(|n| + f(|n|)) steps:The machine works as follows:<br><br>1.Replace the first two inputs of n with A (if the input length n is 1, then 1 will be replaced with A, and when it tries to replace the next A it will reach a space in which it will move on to replace the A back with 1 and then accepts). <br>2. Then read each input from the original input moving right from A on the tape. If you read an A or a 1 on the original input, move to the left of the first A and when you read an empty spot, mark down a one. (As you read each symbol from the original input you should replace it with A or 1, depending on whether it is an A or a 1 so that you know where you left off.)<br>3. After that, move to the right most A and if you read a 1, replace it with an A and repeat the second step. Keep doing this until you reach a empty space on the right side of the tape.<br>4. Once you reach the empty space on the right side of the tape, go back and replace any A with a 1. Then move to the right until you read an empty space, and then accept. <br><br>State the deterministic time hierarchy theorem as presented in class:<br>If f(n)&gt;=n is a proper complexity function, then the class TIME(f(n)) is strictly contained in TIME(f(2n+1)^3). <br><br>Richelle Limun<br>James Yu<br>Cameron Taslim<br>Nanda Guruswamy

-- Practice final problem 7

&#039;&#039;&#039;Originally Posted By: lambert&#039;&#039;&#039;

I cant seem to visualize or follow the steps on how the TM M is working. &lt;br&gt;&lt;br&gt;Cant we make this easy this with a 3-tape machine S by doing the following &lt;br&gt;S takes the input string 1^n. So if n =2, x = &amp;quot;11&amp;quot;&lt;br&gt;S on input x:&lt;br&gt;1.Copies x to tape-2&lt;br&gt;2. rewind both tapes 1 and 2&lt;br&gt;3. Advances one position to the right on tape 2 and see if we read an empty space. If so S halts.&lt;br&gt;4. Scan right on the input tape until we hit an empty square. For every &amp;quot;1&amp;quot; we read write a &amp;quot;1&amp;quot; on tape 3.&lt;br&gt;5. Advances one position to the right on tape 2 and see if we read an empty space. If so S halts.&lt;br&gt;6. Now scan left on the input tape until we hit an empty square. For every &amp;quot;1&amp;quot; we read write a &amp;quot;1&amp;quot; on tape 3.&lt;br&gt;7. go to step 3&lt;br&gt;&lt;br&gt;Eventually tape 2 will hit an empty square and the machine will halt and tape 3 holds n-squared 1&#039;s&lt;br&gt;we can clearly see that this machine runs in n+(n^2) steps and outputs a string n^2 long

'''Originally Posted By: lambert''' I cant seem to visualize or follow the steps on how the TM M is working. <br><br>Cant we make this easy this with a 3-tape machine S by doing the following <br>S takes the input string 1^n. So if n =2, x = &quot;11&quot;<br>S on input x:<br>1.Copies x to tape-2<br>2. rewind both tapes 1 and 2<br>3. Advances one position to the right on tape 2 and see if we read an empty space. If so S halts.<br>4. Scan right on the input tape until we hit an empty square. For every &quot;1&quot; we read write a &quot;1&quot; on tape 3.<br>5. Advances one position to the right on tape 2 and see if we read an empty space. If so S halts.<br>6. Now scan left on the input tape until we hit an empty square. For every &quot;1&quot; we read write a &quot;1&quot; on tape 3.<br>7. go to step 3<br><br>Eventually tape 2 will hit an empty square and the machine will halt and tape 3 holds n-squared 1's<br>we can clearly see that this machine runs in n+(n^2) steps and outputs a string n^2 long

-- Practice final problem 7

&#039;&#039;&#039;Originally Posted By: ngswamy&#039;&#039;&#039;

If you use a 3-tape dosen&#039;t this mean that you would be using a 3n^2 space?&lt;br&gt;&lt;br&gt;&lt;br&gt;Sorry, the algorithm is a bit hard to follow.&lt;br&gt;Say you have input 1111&lt;br&gt;First you would have: AA11&lt;br&gt;Then you read through the original input one time, and each time you read an A or a 1 on the original input, write a 1 to the left of the the leftmost character of the input.&lt;br&gt;&lt;br&gt;1111AA11&lt;br&gt; ^ &lt;br&gt;Next step:&lt;br&gt;1111AAA1&lt;br&gt;11111111AAA1&lt;br&gt;11111111AAAA&lt;br&gt;111111111111AAAA&lt;br&gt;&lt;br&gt;Then replace all A&#039;s with 1&#039;s&lt;br&gt;&lt;br&gt;Final tape: 1111111111111111&lt;br&gt;n now went to n^2 on the tape while still using n^2 space.... hope this helps.&lt;br&gt;Yours might work too, I&#039;m just not sure if it&#039;s done in the n^2 space.

'''Originally Posted By: ngswamy''' If you use a 3-tape dosen't this mean that you would be using a 3n^2 space?<br><br><br>Sorry, the algorithm is a bit hard to follow.<br>Say you have input 1111<br>First you would have: AA11<br>Then you read through the original input one time, and each time you read an A or a 1 on the original input, write a 1 to the left of the the leftmost character of the input.<br><br>1111AA11<br> ^ <br>Next step:<br>1111AAA1<br>11111111AAA1<br>11111111AAAA<br>111111111111AAAA<br><br>Then replace all A's with 1's<br><br>Final tape: 1111111111111111<br>n now went to n^2 on the tape while still using n^2 space.... hope this helps.<br>Yours might work too, I'm just not sure if it's done in the n^2 space.

-- Practice final problem 7

&#039;&#039;&#039;Originally Posted By: lambert&#039;&#039;&#039;

Ok I see now&lt;br&gt;but I didnt use up every space on tape1 or tape 2 so the most would be n+n+(n^2) space from the slide it says:&lt;br&gt;&lt;br&gt;We measure space disregarding the input and output tapes: The input tape is assumed to be read-only and we assume we also have a dedicated, write-only output tape.&lt;br&gt;&lt;br&gt;http://www.cs.sjsu.edu/faculty/pollett/154.1.11s/Lec25042011.html#%283%29&lt;br&gt;So if we ignored input and output tapes the most space I used was n on tape 2&lt;br&gt;&lt;br&gt;Also your algorithm for writing A and rewinding to write the 1&#039;s would seem to take longer than |x| + (|x|)^2 time wouldnt it? since you have to keep scanning back and forth after each 1 you write&lt;br&gt;Imagine on and input of 1111&lt;br&gt;To replace the first 2 inputs to A we used 2 steps tape = AA&lt;br&gt;Writing the first left most 1 takes 2 steps. tape = 1AA11&lt;br&gt;The second 1 takes 5 steps. tape = 11AA11&lt;br&gt;The third 1 takes 9 steps. tape = 111AA11&lt;br&gt;The fourth 1 takes 13 steps. tape = 1111AA11&lt;br&gt;&lt;br&gt;so that would be 31 steps so far. which is larger then 4^2 and we are not even finished yet correct?

'''Originally Posted By: lambert''' Ok I see now<br>but I didnt use up every space on tape1 or tape 2 so the most would be n+n+(n^2) space from the slide it says:<br><br>We measure space disregarding the input and output tapes: The input tape is assumed to be read-only and we assume we also have a dedicated, write-only output tape.<br><br>http://www.cs.sjsu.edu/faculty/pollett/154.1.11s/Lec25042011.html#%283%29<br>So if we ignored input and output tapes the most space I used was n on tape 2<br><br>Also your algorithm for writing A and rewinding to write the 1's would seem to take longer than |x| + (|x|)^2 time wouldnt it? since you have to keep scanning back and forth after each 1 you write<br>Imagine on and input of 1111<br>To replace the first 2 inputs to A we used 2 steps tape = AA<br>Writing the first left most 1 takes 2 steps. tape = 1AA11<br>The second 1 takes 5 steps. tape = 11AA11<br>The third 1 takes 9 steps. tape = 111AA11<br>The fourth 1 takes 13 steps. tape = 1111AA11<br><br>so that would be 31 steps so far. which is larger then 4^2 and we are not even finished yet correct?

-- Practice final problem 7

&#039;&#039;&#039;Originally Posted By: ngswamy&#039;&#039;&#039;

Ohh, okay..yeah then our algorithm won&#039;t work.&lt;br&gt;&lt;br&gt;I think yours works right.

'''Originally Posted By: ngswamy''' Ohh, okay..yeah then our algorithm won't work.<br><br>I think yours works right.
2011-05-18

-- Practice final problem 7

Let me point out the runtime only needs to be O(|x| + (|x|)^2) not |x| + (|x|)^2. That said,&lt;br&gt;The original algorithm I think is Omega(|x|^3), Lambert&#039;s from a casual read looks O(|x| + (|x|)^2).

Let me point out the runtime only needs to be O(|x| + (|x|)^2) not |x| + (|x|)^2. That said,<br>The original algorithm I think is Omega(|x|^3), Lambert's from a casual read looks O(|x| + (|x|)^2).
X