
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Found 282 Articles for Data Structure Algorithms

4K+ Views
The Turing machine (TM) is more powerful than both finite automata (FA) and pushdown automata (PDA). They are as powerful as any computer we have ever built.Formal Definition of Turing MachineA Turing machine can be formally described as seven tuples(Q, X, Σ, δ, q0, B, F)Where, Q is a finite set of statesX is the tape alphabetΣ is the input alphabetδ is a transition function: 𝛿:QxX→QxXx{left shift, right shift}q0 is the initial stateB is the blank symbolF is the final state.A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which ... Read More

3K+ Views
ProblemDesign a DFA for the language L={w1abaw2 | w1, w2 Є(a, b)*}, which means the DFA accepts all strings which contain “aba” as a substring.SolutionThe strings that are accepted by language L= {aba, aabaa, aabab, babab, ababa, …….}Step 1 − Transition diagram for minimal string (starting string) −If w1 and w2 are null then the string it generates is “aba” because w1, w2 ε(a, b)*q0 is the initial state and q3 is the final state.Step 2 − The final DFA for the given language is as follows −Explanationqo is the initial state q0 on ‘a’ goes to q1 and on ... Read More

6K+ Views
The ε transitions in Non-deterministic finite automata (NFA) are used to move from one state to another without having any symbol from the input set Σ.ε-NFA is defined in 5 tuples representation{Q, q0, Σ, δ, F}Where, δ − Q × (Σ∪ε)→2QQ − Finite set of states∑ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition functionNFA without ε transitionNFA is defined in 5 tuples representation{Q, q0, Σ, δ, F}Where, δ − Q X Σ→ 2QQ − Finite set of states∑ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − ... Read More

20K+ Views
The ε transitions in Non-deterministic finite automata (NFA) are used to move from one state to another without having any symbol from input set Σε-NFA is defined in five tuple{Q, q0, Σ, δ, F}Where, δ − Q × (Σ∪ε)→2QQ − Finite set of statesΣ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition functionNFA without ε transitionNFA is defined in 5 tuple representation{Q, q0, Σ, δ, F}Where, δ − Q X Σ→ 2QQ − Finite set of statesΣ, − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition functionNFA ... Read More

809 Views
Let us take a string S of size N, we have to design a Deterministic Finite Automata (DFA) for accepting the language L = {aN | N ≥ 1}.The string accepting the language L is {a, aa, aaa, aaaaaaa…, }.Now the user has to enter a string, if that string is present in the given language, then print “entered string is Accepted”. Otherwise, print “entered string is not Accepted”.DFA transition diagram for the given language is −ExampleFollowing is the C program to construct DFA which accepts the language L = {aN | N ≥ 1} −#include int main() { char S[30]; ... Read More

9K+ Views
The ∈ transitions in Non-deterministic finite automata (NFA) are used to move from one state to another without having any symbol from input set Σ∈-NFA is defined in five tuple representation{Q, q0, Σ, δ, F}Where, δ − Q × (Σ∪∈)->2QQ − Finite set of statesΣ − Finite set of the input symbolq0 − Initial stateF − Final stateδ: Transition functionNFA without ε transitionNFA also has five states same as DFA, but with different transition function, as shown follows −$$\delta\colon\:Q\times\:\sum\longrightarrow\:2^{Q}$$Where, Q − Finite set of statesΣ − Finite set of the input symbolq0 − Initial stateF − Final stateδ − Transition ... Read More

15K+ Views
Design a Deterministic Finite Automata (DFA) for accepting the language L = (a+aa*b)* If the given string is accepted by DFA, then print “string is accepted”. Otherwise, print “string is rejected”.Example 1Input: Enter Input String aaaba Output: String Accepted.Explanation − The given string is of the form (a+aa*b)* as the first character is a and it is followed by a or ab.Example 2Input: Enter Input String baabaab Output: String not Accepted.The DFA for the given regular expression (a+aa*b) is −Explanation −If the first character is always a, then traverse the remaining string and check ... Read More

11K+ Views
Regular grammar describes a regular language. It consists of four components, which are as follows −G = (N, E, P, S)Where, N: finite set of non-terminal symbols, E: a finite set of terminal symbols, P: a set of production rules, each of one is in the formsS → aBS → aS → ∈, S ∈ N is the start symbol.The above grammar can be of two forms −Right Linear Regular GrammarLeft Linear Regular GrammarNow, let us see the steps to convert left linear grammar to right linear grammar −Example 1Consider a left linear grammar as given below −S→ Sa|Abc A→ ... Read More

6K+ Views
For every finite automata (FA) there exists a regular grammar and for every regular grammar there is a left linear and right linear regular grammar.Example 1Consider a regular grammar − a(a+b)* A → aB B → aB|bB|eFor the given regular expression, the above grammar is right linear grammar.Now, convert the above right linear grammar to left linear grammar.The rule to follow for conversion is, Finite Automata → Right linearThe reverse of right linear →left linear grammar.So, A → BaB → Ba|Bb|eFinally for every right linear there is aExampleConsider a language {bnabma| n>=2, m>=2}The right linear grammar for the given language ... Read More

5K+ Views
Regular grammar describes a regular language. It consists of four components, which are as follows −G = (N, E, P, S)Where, N − finite set of non-terminal symbols, E − a finite set of terminal symbols, P − a set of production rules, each of one is in the formsS → aBS → aS → ∈, S ∈ N is the start symbol.The above grammar can be of two forms −Right Linear Regular GrammarLeft Linear Regular GrammarLinear GrammarWhen the right side of the Grammar part has only one terminal then it's linear else nonv linear.Left linear grammarIn a left-regular grammar ... Read More