Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
aa:lab:02 [2020/10/15 15:04]
pdmatei
aa:lab:02 [2020/10/22 10:25] (current)
pdmatei
Line 58: Line 58:
   * how would ''​s += x''​ be implemented?​   * how would ''​s += x''​ be implemented?​
   * how would ''​if (s > M) then ... else ...''​ be implemented ?   * how would ''​if (s > M) then ... else ...''​ be implemented ?
 +
 +/*
  
 **Answer:** **Answer:**
Line 69: Line 71:
   * After ''​!''​ is read on the tape, we know we have finished the ''​foreach''​. We can then implement a bit-wise comparison of the values ''​s''​ and ''​M'',​ which would now be the current value of the tape. The machine accepts if ''​s > M''​.   * After ''​!''​ is read on the tape, we know we have finished the ''​foreach''​. We can then implement a bit-wise comparison of the values ''​s''​ and ''​M'',​ which would now be the current value of the tape. The machine accepts if ''​s > M''​.
  
 +*/
 ==== More practice exercises ==== ==== More practice exercises ====
   * Write a TM which verifies if a string has the **same number** of ones and zeroes. Give hints - live (what should the machine do?)   * Write a TM which verifies if a string has the **same number** of ones and zeroes. Give hints - live (what should the machine do?)