Theory of Computation Submitted to Dr Arshad sb
Muhammad Haseeb(19PRI24426)

Algorithm 01

Keep two binary flags, the a-flag and the b-flag. Every time an a is read, the a-flag is reversed (0 to 1, or 1 to 0); and every time a b is read, the b-flag is reversed. We start both flags at 0 and check to be sure they are both 0 at the end.

4 characters • only a and b accepted

Try an example
A-FLAGtoggles on “a”
A0
B-FLAGtoggles on “b”
B0

FINAL RESULT

Valid

00
PROCESS TRACE