Found 282 Articles for Data Structure Algorithms

Explain Operator grammar and precedence parser in TOC

Bhanu Priya
Updated on 15-Jun-2021 11:29:18

3K+ Views

If the grammar satisfies the following two conditions, then we can say that type of grammar is called as operator precedence grammar.If ε is on its RHS then there exists no production rule.If two non-terminals are adjacent to each other on its RHS then there exists no production rule.Operator Grammars have the property that no production right side is empty or has two adjacent non-terminals.ExampleE-> E A E | idA-> + | *The above grammar is not an operator grammar but we can convert that grammar into operator grammar like −E-> E + E | E * E | idThere ... Read More

How to convert CFG to Greibach Normal Form?

Bhanu Priya
Updated on 15-Jun-2021 11:26:20

17K+ Views

A Context Free Grammar (CFG) is said to be in Greibach Normal Form(GNF), if production rules satisfy one of the following criteria −Only a start symbol can generate ε. For example, if S is the start symbol then S → ε is in GNF.A non-terminal can generate a terminal. For example, if A is Non terminal and a is terminal then, A → a is in GNF.A non-terminal can generate a terminal followed by any number of non-terminals. For Example, S → aAS is in GNF.Case 1G1 = {S → aAB | aB, A → aA| a, B → bB ... Read More

Explain Union and Intersection of Regular languages with CFL

Bhanu Priya
Updated on 15-Jun-2021 11:24:21

2K+ Views

We know that the languages accepted by finite automata (FA) are called regular languages and the languages accepted by push down automata (PDA) are called context free languages (CFG).Closure of CFLs under UnionCFL is the short form for Context Free Language. Here the CFL is as follows −G = (V, Σ, R, S) such that L(G) = L(G1) ∪ L(G2)Thus, V = V1 ∪ V2 ∪ {S} (the three sets are disjoint)Σ = Σ1 ∪ Σ2R = R1 ∪ R2 ∪ {S → S1|S2}Union of Regular language with CFGIf all regular languages are context-free then union of both results is ... Read More

Differentiate between Mealy machine and Moore machine in TOC

Bhanu Priya
Updated on 15-Jun-2021 11:21:53

18K+ Views

Mealy MachineIn a Mealy machine the output symbol depends upon the present input symbol and present state of the machine.In the Mealy machine, the output is represented with each input symbol and each state is separated by /.The Mealy machine can be described by six tuples (Q, q0, Σ, O, δ, λ')Where, Q: Finite set of states.q0: Initial state of machine.Σ: Finite set of input alphabet.O: Output alphabet.δ: Transition function where Q × Σ → Q.λ': Output function where Q × Σ → O.In the Mealy machine, the output is represented with each input symbol and each state is separated ... Read More

Explain the cross product method process in DFA

Bhanu Priya
Updated on 15-Jun-2021 07:01:52

2K+ Views

The cross product method process in the deterministic finite automata (DFA) is explained below −Let a's DFA diagram has m number of states and b's DFA diagram has n number of states the cross product m x n will have mxn states.Languages represented by even number of ‘a’ and even number of ‘b’ are given below −L1 = {ε, baa, aa, aba, aab, aaaa, ... }L2 = {ε bb, abb, bab, bba, ...}After cross product we will find the DFA as mentioned below −As, L = {ab, aab, abb, aaab, ...}ExampleLet’s taken two DFAsEven number of a'sEven number of b'sThe ... Read More

Explain Union process in DFA

Bhanu Priya
Updated on 15-Jun-2021 06:55:09

3K+ Views

The union process in the deterministic finite automata (DFA) is explained below −If L1 and If L2 are two regular languages, their union L1 U L2 will also be regular.For example, L1 = {an | n > O} and L2 = {bn | n > O}L3 = L1 U L2 = {an U bn | n > O} is also regular.ProblemDesign a DFA over an alphabet {a, b} where the start and end are of different symbols.SolutionThere are two different types of languages are formed for a given condition −L1={ab, aab, abab, abb, …….}L1={ab, aab, abab, abb, …….}Here, L1= starts ... Read More

Construct DFA of a string in which the second symbol from RHS is ‘a’

Bhanu Priya
Updated on 15-Jun-2021 06:52:53

3K+ Views

A Deterministic Finite automaton (DFA) is a 5-tuplesM=(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.ProblemDesign a finite automaton where the second symbol from the right hand side is ‘a’.SolutionThe language for a given string over an alphabet {a, b} is −L={aa, abaa, abbab, aaabab, ………}ExampleInput − aabaOutput − Not acceptedBecause the second letter from right hand side is not aInput − aabbabOutput − AcceptedIt is complicated to directly construct ... Read More

Design DFA for language over {0,1} accepting strings with odd number of 1’s and even number of 0’s

Bhanu Priya
Updated on 15-Jun-2021 06:50:08

5K+ Views

A Deterministic Finite automaton (DFA) is a 5-tuplesM=(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.ProblemConstruct a DFA machine accepting odd numbers of 1’s and even number of 0’s.SolutionDesign two separate machines for the two conditions over an alphabet Σ={0, 1}:DFA accepts only an odd number of 1’s.DFA accepts only even number of 0’s.Here, s1 = starts2=odd 1 or start 11s3= starts 11 accepted and stay theres4 = accept even ... Read More

Construct an NFA accepting strings with an even number of 0s or an odd number of 1s

Bhanu Priya
Updated on 15-Jun-2021 06:47:51

13K+ Views

Non-deterministic finite automata (NFA) also have five states which are same as DFA, but with different transition function, as shown follows −δ: Q X Σ → 2QWhere, 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.ProblemConstruct NFA over an alphabet Σ={0, 1}.SolutionDesign two separate machines for the two conditions, as given below −NFA accepting only odd number of 1’sNFA accepting only even number of 0’sNFA accepting only odd number of 1’s over an alphabet Σ= ... Read More

Design a DFA machine accepting odd numbers of 0’s or even numbers of 1’s

Bhanu Priya
Updated on 15-Jun-2021 06:46:13

11K+ Views

A Deterministic Finite automaton (DFA) is a five tuplesM=(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.ProblemConstruct a DFA machine accepting odd numbers of 0’s or even numbers of 1’s.SolutionDesign two separate machines for the two conditions over an alphabet Σ={0, 1} −DFA accepting only odd number of 0’sDFA accepting only even number of 1’sDFA accepting only odd number of 1’s over an alphabet Σ={0, 1}    The language L= ... Read More

Previous 1 ... 7 8 9 10 11 ... 29 Next
Advertisements