Write a CFG Grammar for $L=\left\{ a^ib^jc^k\mid i+k=3j \right\}$
I'm having trouble because the j is in the middle so I keep getting c's before b's. I feel I'm missing something simple.
Write a CFG Grammar for $L=\left\{ a^ib^jc^k\mid i+k=3j \right\}$
I'm having trouble because the j is in the middle so I keep getting c's before b's. I feel I'm missing something simple.
Copyright © 2021 JogjaFile Inc.
I think this will do it:
$S \rightarrow \varepsilon |aAbBcc|aaAbBc|aaaAbbBccc$
$A\rightarrow aaaAb|\varepsilon $
$B \rightarrow bBccc | \varepsilon $
The trick for me was having the first rule determine the differenace between $i$ and $k$ and then the other rules just preserve that.