308 views

1 Answer

Best answer
3 votes
3 votes

Answer: (d)
Just see the diagram,

State q1 – q2: Push $ on the top of the stack,

State q2: On getting 0 or 1 in the input push it on the top of the stack

State q2 – q3: On getting 0 or 1 in the input don’t push anything on stack just go to state q3. 

State q3: On getting 0 in the input if top of the stack is 0 pop it, similarly on getting 1 in the input if top of the stack is 1 pop it.
State q3 – q4: If top of the stack is $ pop it and go to q4 and accept the input string.

Now notice string will be a palindrome, example
01010

Initially 0 and 1 are pushed on to the stack. Now on 0 it will go to the state q3. 1 is on the top of the stack and next input is also 1 so it is popped off. Similarly 0 will pop. Now top of the stack is $ so it will move from state q3 to q4 and string is accepted.

Why length of palindrome can’t be even?

Let’s assume we push $x$ number of alphabets on to the stack, we need one alphabet to go from state q2 to q3 in order to pop alphabets from the stack. And we need to pop $x$ alphabets.

Therefore total alphabets in input string should be $x + 1 + x = 2x + 1$ which is odd.

selected by

Related questions

0 votes
0 votes
1 answer
1
SKMAKM asked Jul 19, 2022
350 views
Please explain the ans. Ans is (B)
2 votes
2 votes
3 answers
2
SKMAKM asked Jul 14, 2022
513 views
please explain it how to solve such question in examAns: 22
0 votes
0 votes
0 answers
3
SKMAKM asked Oct 22, 2022
425 views
Answer -3.7
0 votes
0 votes
2 answers
4
SKMAKM asked Oct 21, 2022
349 views
Answer 1.18