

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What happens when a String is accepted or rejected by NPDA?
A string is accepted by an Non-deterministic Push down Automata (NPDA), if there is some path (i.e., sequence of instructions) from the start state to a final state that consumes all the letters of the string. Otherwise, the string is rejected by the NPDA.
The language of an NPDA is the set of all strings that it accepts.
An input string rejected by the NPDA under following conditions −
If reading an input string finishes without reaching a final state.
If for a current state/symbol on the stack/input symbol there is no transition.
If it attempts to pop the empty stack.
Example
Build an NPDA which recognises the context-free language
L = {anbn| n > 0}.
Steps
Follow the steps given below to build a NPDA −
Begin reading the string, and for each a read, push a Y onto the stack.
On the first b change states, and begin removing one Y from the stack for each b.
If you reach the end of the input and have just cleared the stack, accept the string.
Otherwise, reject. For example, if the stack runs out before the input –more b’s than a’s.
Push down automata for { anbn , n>=0}
Three states − 0 (start), 1, 2(final)
Input alphabet − {a,b}
Stack alphabet − { Y,$}
The push down automata will be as follows −
There are six allowed instructions for this NPDA, which are as follows −
T1 − (0, a, $, push(Y), 0)
T2 − (0, a, Y, push(Y), 0)
T3 − (0, ∧, $, nop, 2)
T4 − (0, b, Y, pop, 1)
T5 − (1, b, Y, pop, 1)
T6 − (1, ∧, $, nop, 2)
Reading $ corresponds to checking if the stack is empty.
- Related Questions & Answers
- What happens when we type a URL?
- What happens when you add a double value to a String in java?
- What Happens When You Quit Smoking?
- What happens when a function is called before its declaration in C?
- What happens when JDialog is set with Modality type APPLICATION_MODAL
- What happens when serum calcium level drops?
- What happens when you control your mind?
- What happens when a negative value is inserted to UNSIGNED column in MySQL?
- What happens when a subclass object is assigned to a superclass object in Java?
- What happens when length of object is set to 0 - JavaScript?
- What happens when a virtual function is called inside a non-virtual function in C++
- What happens when buffer is set to a value "none" in JSP?
- What happens when JDialog is set with Modality type MODELESS in Java
- What happens when you do not declare a variable in JavaScript?
- What happens when you declare a method/constructor final in Java?