Which of the following languages are context-free? L1={ambnanbm|m,n≥1} L2={ambnambn|m,n≥1} L3={ambn|m=2n+1}
Open in App
Solution
L1={ambnanbm|m,n≥1} is CFL (push "a" and "b" and then first "a" pops "b" and then "b" pops "a"). L2={ambnambn|m,n≥1} is non-CFL (Alternate comparision not possible in a PDA) L3={ambn|m=2n+1} is CFL (Single comparison is possible in a PDA)