Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
aa:lab:02 [2020/10/10 09:33]
pdmatei
aa:lab:02 [2020/10/22 10:25] (current)
pdmatei
Line 33: Line 33:
 **1.2** Write a TM which **enters the final state** only if the **input** is a binary encoding of an **even** natural number. **1.2** Write a TM which **enters the final state** only if the **input** is a binary encoding of an **even** natural number.
  
-**1.3** Write a TM which **enters the final state** only if the **input** is a binary encoding of an **odd** natural number.+**1.3** Write a TM which verifies ​if a given word over alphabet $math[{A,​B}] contains ​the sequence ''​ABA''​.
  
-**1.4** ​ Write a TM which adds **5** to a number encoded in binary on the tape. +**1.4** Write a TM which adds **5** to a number encoded in binary on the tape. 
  
-**1.5** Write a machine ​which checks if a symbol ​is present on the tapeThe machine should accept if this is so.+**1.5** Write a TM which checks if a binary number ''​x'' ​is strictly larger than ''​y''​Hint: use a separator symbol between words.
  
 ==== 2. Algorithms and Turing Machines ==== ==== 2. Algorithms and Turing Machines ====
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?)