I am trying to apply the CNF algorithm to this grammar :
$S \to NT $
$N \to aNb | ε$
$T \to bTcc | ε$
Here is what I have done with all the steps,however at the end my answer is way different from the one in the book and I can't seem to find my mistake here is my soluton:
First I have removed the long rules and added the rules in the form $X \to m$ Then the grammar becomes :
$S \to NT$
$N \to A_{4}A_{1} | ε $
$A_{1} \to NA_{5} $
$T \to A_{5}A_{2} | ε $
$A_{2} \to TA_{3} $
$A_{3} \to A_{6}A_{6} $
$A_{4} \to a$
$A_{5} \to b$
$A_{6} \to c$
Now for eliminating the $ε$ rules I got :
$S \to NT | N | T$
$N \to A_{4}A_{1} $
$A_{1} \to NA_{5} | A_{5}$
$T \to A_{5}A_{2} $
$A_{2} \to TA_{3} | A_{3} $
$A_{3} \to A_{6}A_{6} $
$A_{4} \to a$
$A_{5} \to b$
$A_{6} \to c$
Here there are no cycles ,so we can just set the renaming rules and I got :
$S \to NT | A_{4}A_{1} | A_{5}A_{2}$
$N \to A_{4}A_{1} $
$A_{1} \to NA_{5} | A_{4}A_{1}$
$T \to A_{5}A_{2} $
$A_{2} \to TA_{3} | A_{6}A_{6} $
$A_{3} \to A_{6}A_{6} $
$A_{4} \to a$
$A_{5} \to b$
$A_{6} \to c$