Question

In: Computer Science

Construct an NPDA that accepts the language defined by the given grammar and give the language...

Construct an NPDA that accepts the language defined by the given grammar and give the language in a formal expression (including a regular expression).

S -> AA|a, A-> SA|ab

Solutions

Expert Solution

Here from the given grammar first of all ,we must find the language accepted. For that we must find the various strings accepted to provide a formal expression language.

From the possible strings that can be formed, we get

L(G)= {a,abab,ababab,a^2ba^2b,...}
Therefore, L={a^m b^n/m>=n,n>=0}

Now let us construct the corresponding NDPA.

Logic:

In each string there are 'm' number of a's and 'n' number of b's. The number of b's is either equal to the number of a's or less than the number of a's.Thus we need a stack along with the state diagram.The count of a's and b's are maintained by the stack. We will take two stack alphabets.

T={a,z} where T= set of all the stack alphabets and z= stack start symbol.

Approach used in construction of NDPA:

Whenever 'a' comes, push it in to the stack and if 'a' comes again do the same. When 'b' comes then pop one 'a' from the stack.

So that the stack either becomes empty or will have 'a' only left out. If stack is empty or have some left out a's we can say that the string is accepted by the NPDA.

The stack transition function and transition diagram are attached as handwritten copy as the symbols used in keyboard may bring you confusions regarding the symbols.


Related Solutions

Construct a pda that accepts the language defined by the grammar S → aSSSab | λ...
Construct a pda that accepts the language defined by the grammar S → aSSSab | λ . This has already been answered using software with no explanation. I am not interested in the answer so much. I just want an explanation. or at least a step by step formula.
a) Give 5 good examples of Regular language. b) Give 5 good examples of Regular Grammar.
a) Give 5 good examples of Regular language. b) Give 5 good examples of Regular Grammar.
Construct a dfa that accepts strings on {0, 1} if and only if the value of...
Construct a dfa that accepts strings on {0, 1} if and only if the value of the string, interpreted as a binary representation of an integer, is zero modulo five. For example, 0101 and 1111, representing the integers 5 and 15, respectively, are to be accepted.
Define a PDA that accepts language L3 = { anbm | n > 0 and n...
Define a PDA that accepts language L3 = { anbm | n > 0 and n > m }. Implement that PDA in JFLAP. Must use JFLAP
Now that you know a bit about BNF's, try writing a grammar (productions) for the "language"...
Now that you know a bit about BNF's, try writing a grammar (productions) for the "language" of a phone number, which consists of: three digits enclosed in parentheses - the first digit cannot be "0" (zero) followed by three digits - the first digit cannot be "0" (zero) followed by a "-" (dash) followed by four digits So, (757)530-4601 is a valid phone number. All the following numbers are invalidaccording to this grammar: 757-530-4601 (area code is not in parentheses)...
Write a program in python language, which accepts 2 numbers and a + sign (for addition)...
Write a program in python language, which accepts 2 numbers and a + sign (for addition) A sign - (for subtraction) A sign * (for multiplication), / (for division) Then calculate and to display the result of the operation he chose with the two numbers. Displaying the appropriate message
R programming language A) Create a function that accepts two arguments, an integer and a vector...
R programming language A) Create a function that accepts two arguments, an integer and a vector of integers. It returns the count of the number of occurrences of the integer in the input vector. 1]Input: num_count <-function ??? 2]Input: num_count(2,c(1,1,2,2,3,3)) 2] Output: 2 3] Input: num_count(1,c(1,1,2,2,3,1,4,5,5,2,2,1,3)) 3] Output : 4 B) Create a function that accepts 3 integer values and returns their sum. However, if an integer value is evenly divisible by 3, then it does not count towards the...
C++ language Write a program that accepts as input the base price and the finished area...
C++ language Write a program that accepts as input the base price and the finished area in square feet of the three models. The program outputs the model(s) with the least price per square foot in the following format: If the colonial model is the least price, output: The price per square foot of the colonial model is the least. If the split-entry model is the least price, output: The price per square foot of the split-entry model is the...
if language is defined as being open what does it mean
if language is defined as being open what does it mean
Question II: Consider the language L below. If L is a regular language, construct the corresponding...
Question II: Consider the language L below. If L is a regular language, construct the corresponding DFA. If not, prove that L is not a regular language. L= {0n10n | n ≥1} Consider the language M consisting of those strings of 0’s and 1’s that have an equal number of 0’s and 1’s (not in any particular order). Suppose we know M is not a regular language. Consider the language N consisting of those strings of 0’s and 1’s that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT