← RGPV CS-501-CBGS Theory of Computation June 2020 Solved Paper
Question
Design Turing machine to add two number a and b.
Asked in: CS-501 | June 2020 | 1(b)
Answer
Assume nonnegative integers a,b encoded in unary as 1ᵃ#1ᵇ. Replace the separator # with 1, then erase the last 1 to leave 1ᵃ⁺ᵇ. Start q0 scanning the first symbol. In q0 on 1 move right unchanged; on # write 1, move right to q1. In q1 on 1 move right; on blank move left to q2. In q2 on 1 write blank and halt in qf. For 11#111, the tape becomes 111111 then 11111. The algorithm also handles zero operands, including # alone. It halts after a linear number of steps on valid input. Binary addition would require a different encoding and carry algorithm; the question does not specify the representation.

← RGPV CS-501-CBGS Theory of Computation June 2020 Solved Paper
Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion