UNIVERSITY AT BUFFALO, THE STATE UNIVERSITY OF NEW YORK
The Department of Computer Science & Engineering
cse@buffalo
UB CSE 111

 

Homework 6

12 points
Due Monday July 25, 2011
  1. Define a TM and show a flowchart for a program which finds the XOR of two values. The input tape will contain two binary numbers, and the tape after execition should contain three - with the last one being the truth value of the XOR. For example, assume the input was 10, then the tape after execution would contain 101. If the input tape contained 11, the tape after execition would contain 110. [6pts]
  2. Define a TM and show a flowchart for a program which adds two unary numbers together. A unary number is a number which consists of only '1's. For example, if we wanted to express the number 5 in unary, we would write '11111', that is, five ones. The addition problem of m + n will be expressed on the tape as m '1's, followed by a 0, followed by n '1's. For example: we wish to add 3 and 4, the input tape contains: 11101111 (that is 3 '1's, followed by a 0, followed by 4 '1's). Our output tape should contain 1111111 (that is, 7 '1's). [6pts]