How do I convert below grammar to CNF?
S → ASA | aB
A → B | S
B → b | ε
We can split the transformation of context free grammars to Chomsky Normal Form into four steps.
From your example, describing each step, the transformation to CNF can look like the following.
Alternatives in production S is split up into smaller productions. New non-terminals are T.
S → AT | aB
A → B | S
B → b | ε
T → SA
From the production of S, nullable non-terminals A and B were factored out.
S → AT | T | aB | a
A → B | S
B → b | ε
T → SA
For the production of A, no action need be taken.
S → AT | T | aB | a
A → B | S
B → b | ε
T → SA
From the production of B, empty string tokens were removed.
S → AT | T | aB | a
A → B | S
B → b
T → SA
From the production of T, nullable non-terminal A were factored out.
S → AT | T | aB | a
A → B | S
B → b
T → SA | S
"Inlined" the production for B in A.
S → AT | T | aB | a
A → b | S
B → b
T → SA | S
Replaced a terminal "a" in production S with the new non-terminal U.
S → AT | T | UB | a
A → b | S
B → b
T → SA | S
U → a
And you're done.