
- 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
Construct DFA of a string in which the second symbol from RHS is ‘a’
A Deterministic Finite automaton (DFA) is a 5-tuples
M=(Q, Σ, δ,q0,F)
Where,
- Q : Finite set called states.
- Σ : Finite set called alphabets.
- δ : Q × Σ → Q is the transition function.
- q0 ϵ Q is the start or initial state.
- F : Final or accept state.
Problem
Design a finite automaton where the second symbol from the right hand side is ‘a’.
Solution
The language for a given string over an alphabet {a,b} is −
L={aa,abaa,abbab,aaabab,………}
Example
Input − aaba
Output − Not accepted
Because the second letter from right hand side is not a
Input − aabbab
Output − Accepted
It is complicated to directly construct the DFA.
So, first try to design the non-deterministic finite automata (NFA) and then convert it to the deterministic finite automata (DFA).
Now construct the NFA of the language containing all the strings where the 2nd symbol from the RHS is “a” is given below −
Here,
- A is the initial state.
- B is the intermediate state and
- C is the final state.
Construct NFA transition table. With the help of a transition table, it is easy to convert the DFA transition table from there to a DFA transition diagram.
The NFA transition table is as follows −
Now convert this NFA transition table to DFA transition table.
We can do this by using the subset configuration on the state transition table of NFA.
The DFA transition table is as follows −
Now, it is comparatively easy to draw the DFA with the help of its transition table.
In this DFA, there are four different states A, AB, ABC and AC, where ABC and AC are the final states because c is the final state in NFA, wherever C is present that state becomes the final state and A is the initial state of the DFA.
- Related Questions & Answers
- Construct DFA beginning with ‘a’ but does not have substring ‘aab’
- Draw DFA which accepts the string starting with ‘ab’.
- Design a DFA accepting stringw so that the second symbol is zero and fourth is 1
- Construct DFA of alternate 0’s and 1’s
- Program to build DFA that starts and ends with ‘a’ from the input (a, b)
- Program to build DFA that starts and end with ‘a’ from input (a, b) in C++
- In the query [SELECT column1, column2 FROM table_name WHERE condition; ] which clause among ‘SELECT’, ‘WHERE’ and ‘FROM’ is evaluated in the last by the database server and why?
- C Program to construct a DFA which accepts L = {aN | N ≥ 1}
- Validate input: replace all ‘a’ with ‘@’ and ‘i’ with ‘!’JavaScript
- What is the benefit of MySQL ‘IS NULL’ and ‘IS NOT NULL’?
- What is the use of ‘ALL’, ‘ANY’, ’SOME’, ’IN’ operators with MySQL subquery?
- Count of sub-strings that do not contain all the characters from the set {‘a’, ‘b’, ‘c’} at the same time in C++
- Write a program in Python to filter the elements in a series which contains a string start and endswith ‘a’
- Is the second string a rotated version of the first string JavaScript
- MySQL query to search a string ‘demo’ if someone mistakenly types ‘deom’?