Question: Show, step by step, how the following pushdown automaton - - that checks whether a word consisting of letters S and R corresponds to a

Show, step by step, how the following pushdown automaton -- that checks whether a word consisting of letters S and R corresponds to a situation in which there are at least twice as many rest hours as study hours -- will accept the word RSR. This pushdown automaton has three main states:
the starting state s,
the working state w, and
the final state f,
and several intermediate states.
In the stack, in addition to the bottom symbol $, we have:
either one or several Ns -- indicating the difference between twice the number of study hours and the number of rest hours so far (if this difference is positive),
or one or several Rs -- indicating the difference between the number of rest hours and twice the number of study hours (if this difference is positive).
The transitions are as follows:
From s to w, the transition is \epsi ,\epsi -> $.
From w to f, the transition is: \epsi ,\epsi ->\epsi .
From f to f, we have two transitions: \epsi , R ->\epsi and \epsi , $ ->\epsi .
From w to w, we have the following transitions:
If we see the symbol R and $ is on top of the stack, we keep the dollar sign and add R to the stack, i.e., we have transition R, $ -> $ that brings us to an intermediate state a1, and then the transition \epsi ,\epsi -> R that brings us back to the working state.
If we see the symbol R and R is on top of the stack, we keep the top R and add another R to the stack, i.e., we have transition R, R -> R that brings us to an intermediate state a2, and then the transition \epsi ,\epsi -> R that brings us back to the working state.
If we see the symbol R and N is on top of the stack, we delete the top N, i.e., we have transition R, N ->\epsi .
If we see the symbol S and $ is on top of the stack, we keep the dollar sign and add two Ns to the stack, i.e., we have transition S, $ -> $ that brings us to an intermediate state a3, then the transition \epsi ,\epsi -> N that brings us to an intermediate state a4, and then the transition \epsi ,\epsi -> N that brings us back to the working state.
If we see the symbol S and N is on top of the stack, we keep the top N and add two more Ns to the stack, i.e., we have transition S, N -> N that brings us to an intermediate state a5, then the transition \epsi ,\epsi -> N that brings us to an intermediate state a6, and finally the transition \epsi ,\epsi -> N that brings us back to the working state.
If we see the symbol S and R is on top of the stack, we first delete the top R from the stack, i.e., we have transition S, R ->\epsi , and move to an intermediate state a7.
If in this state, we see R on top of stack, we delete this R and go back to the working state; the transition is \epsi , R ->\epsi
if in this state, we see $ on top of the stack, we add N, i.e., first we apply the transition \epsi , $ ->\epsi and go to the intermediate state a8, and then we apply the transition \epsi ,\epsi -> N, and go to the working state.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!