Turing machine for 0ⁿ1ⁿ2ⁿ

December 4, 2026 · Team EasyExamNotes · 2 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CD-501 Theory of Computation December 2024 Solved Question Paper

Question

Construct a TM accepting L={0ⁿ1ⁿ2ⁿ | n≥0} over {0,1,2}.

Asked in: CD-501 | December 2024 | 5(b)

Answer

Use a deterministic single-tape TM with tape alphabet {0,1,2,X,Y,Z,blank}. First scan the input to verify it has form 0*1*2*, rejecting any violation. Return to the left end. The empty input is accepted.

In state A, skip X and mark the first unmarked 0 as X. In B, scan right past 0 and Y until an unmarked 1 is found; mark it Y. If a 2, Z or blank appears first, reject. In C, scan right past 1 and Z until an unmarked 2 is found; mark it Z. If blank appears first, reject. In D, return left to the blank and move right to A.

When A finds Y, Z or blank instead of an unmarked 0, verify that all remaining symbols are Y or Z and then accept at blank. Reject any remaining unmarked symbol. All unspecified transitions reject.

State Read Action
A X move R
A 0 write X, R, B
A Y/Z keep, R, E
A blank accept
B 0/Y move R
B 1 write Y, R, C
C 1/Z move R
C 2 write Z, L, D
D nonblank move L
D blank move R, A
E Y/Z move R
E blank accept

Example: 001122 becomes X0Y1Z2 and then XXYYZZ. Each completed cycle marks exactly one symbol of each kind. The initial order check and final verification ensure equality of counts and correct ordering. Each cycle removes one unmarked zero, so the machine halts on every input.

Turing machine for 0ⁿ1ⁿ2ⁿ
Turing machine for 0ⁿ1ⁿ2ⁿ

← RGPV CD-501 Theory of Computation December 2024 Solved Question Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion