496 views
2 votes
2 votes
Which of the following is/are CFL?

1) L = { xy | |x|=|y| }

2) L = { x#y | |x|=|y| }

1 Answer

2 votes
2 votes
Both 1 and 2 are CFL.

as both can be accepted by using push down automata.

Language 1 generates the strings of type xy ,xxyy, xxxyyy and so on which can be accepted by pushing all x into the stack and then for every y pop one x out of the stack .

Language 2 generates the strings of type x#y, xx#yy, xxx#yyy and so on which can be accepted by pushing all x into the stack after that we have to skip the # and then for every y we have to pop one x out of the stack.

In both cases the PDA accepts the string with empty stack .

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2
practicalmetal asked Mar 15, 2023
514 views
Is the following language context free:The set of all strings with number of a’s equal to number of b’s and the sum of a’s and b’s to be divisible by 3.