Open In App

Construct a Turing machine for L = {a<sup>i</sup>b<sup>j</sup>c<sup>k</sup> | i < j < k or i > j > k}

Prerequisite – Turing Machine
The language L = {aibjck | i < j < k or i > j > k} is same as the union of two languages L1={aibjck | i < j < k } and L2={aibjck | i > j > k }
In this language, every string of ‘a’, ‘b’ and ‘c’ have certain number of a’s, then certain number of b’s and then certain number of c’s.

Input: a a a b b c  
       Here a = 3, b = 2, c = 1
Output: ACCEPTED
          
Input: a b b c c c
       Here a = 1, b = 2, c = 3 
Output: ACCEPTED

Input: a a b b c c c
       Here a = 2, b = 2, c = 3 but |a|>|b|>|c| or |a|<|b|<|c|
Output: NOT ACCEPTED 

Tape Representation:

Approach:

  1. Comparing two elements by making two element as a single element.
  2. After that the elements which are treated as single element are compared again .
  3. If |First| is greater than |(Second, Third)| and |Second| greater than |Third|, then it is accepted.
  4. If |Third| is greater than |(First, Second)| and |First| greater than |Second|, then it is accepted.
  5. Else it is not accepted.

Steps:

State transition diagram :

Here, Q0 shows the initial state and Q1, Q2, Q3, Q4, Q5, Q6, Q8, Q9, Q10 shows the transition state and Q7 and Q11 shows the final state. A, C, D are the variables used and R, L shows right and left.

Explanation:

Note: For comparison of |A|, |D|, |C|, the concept of Turing Machine as Comparator is used

Article Tags :