So, at first I was doing wrong and unable to find the logic. I first output 'aabb' as the language says i >= 2, j=> 2. Then I put the logic for other a's and b's into them. So, according to that logic the final state diagram is: Final Turing Machine