Found 345 Articles for Data Structure Algorithms

Explain the method for constructing Minimum Finite State Automata.

Bhanu Priya
Updated on 12-Jun-2021 09:54:00

2K+ Views

A finite state machine (FSM) which has a set of states and two functions called the next-state and output function.The set of states correspond to all the possible combinations of the internal storage.If there are n bits of storage, there are 2n possible states.The next state function is a combinational logic function that given the inputs and the current state, determines the next state of the systemA Finite State Machine consists of the following −K states: S = {s1, s2, ... ,sk}, s1 is initial stateN inputs: I = {h, i2, ... ,in}M outputs: O = {o1, o2, . ,om}Next-state ... Read More

How to convert NFA with epsilon to DFA in TOC?

Bhanu Priya
Updated on 13-Sep-2023 16:13:10

37K+ Views

In this method, we first convert Non-deterministic finite automata (NFA) with ε to NFA without ε.Then, NFA without ε- can be converted to its equivalent Deterministic Finite Automata (DFA).Method for conversionThe method for converting the NFA with ε to DFA is explained below −Step 1 − Consider M={Q, Σ, δ, q0, F) is NFA with ε. We have to convert this NFA with ε to equivalent DFA denoted byM0=(Q0, Σ, δ0, q0, F0)Then obtain, ε-closure(q0) ={p1, p2, p3, ……pn}then [p1, p2, p2, ….pn] becomes a start state of DFAnow[p1, p2, p3, ….pn] ∈ Q0Step 2 − We will obtain δ ... Read More

How to convert NFA with epsilon to without epsilon?

Bhanu Priya
Updated on 12-Jun-2021 09:49:28

28K+ Views

In this method, we try to remove all the ε-transitions from the given Non-deterministic finite automata (NFA) −The method is mentioned below stepwise −Step 1 − Find out all the ε-transitions from each state from Q. That will be called as ε-closure(qi) where, qi ∈Q.Step 2 − Then, 𝛿1 transitions can be obtained. The 𝛿1 transitions means an ε-closure on 𝛿 moves.Step 3 − Step 2 is repeated for each input symbol and for each state of given NFA.Step 4 − By using the resultant status, the transition table for equivalent NFA without ε can be built.NFA with ε to ... Read More

What is an epsilon closure in TOC?

Bhanu Priya
Updated on 12-Jun-2021 09:44:40

15K+ Views

The ε closure(P) is a set of states which are reachable from state P on ε-transitions.The epsilon closure is as mentioned below −ε-closure (P) = P, where P ∈ QIf there exists ε-closure (P) = {q} and 𝛿(q, ε) =r then, ε-closure (P) = {q, r}ExampleFind ε-closure for the following Non-deterministic finite automata (NFA) with epsilon.Solutionε-closure (q0)= {q0, q1, q2}self state+ ε-reachable states.ε-closure (q1)= { q1, q2}q1 is self-state and q2 is a state obtained from q1 with epsilon input.ε-closure (q2)= {q2}Lets us consider an example to understand more clear about epsilon closure −Problem − find the number of epsilon ... Read More

What is an acceptance of language by NFA with Epsilon?

Bhanu Priya
Updated on 12-Jun-2021 09:41:39

5K+ Views

The language L accepted by Non-deterministic finite automata (NFA) with ε, denoted by M= (Q, Σ, 𝛿, q0, F) and can be defined as follows −Let M= (Q, Σ, 𝛿, q0, F) be a NFA with εWhere, Q is a set of statesΣ is input setδ is a transition function from Q x { Σ U ε } to 2Qq0 is start stateF is a final stateThe string w in L accepted by NFA can be represented as follows −L(M)={w| w ∈ Σ* and 𝛿 transition for w from q0 reaches to F}ExampleConstruct NFA with epsilon which accepts a language ... Read More

How to convert the finite automata into regular expressions?

Bhanu Priya
Updated on 12-Jun-2021 09:33:56

8K+ Views

ProblemConvert the given finite automata (FA) into regular expression (RE).SolutionThere are two popular methods for converting a DFA to its regular expression −Arden’s MethodState elimination methodLet’s consider the state elimination method to convert FA to RE.RulesThe rules for state elimination method are as follows −Rule 1The initial state of DFA must not have any incoming edge.If there is any incoming edge to the initial edge, then create a new initial state having no incoming edge to it.Rule 2There must exist only one final state in DFA.If there exist multiple final states, then convert all the final states into non-final states ... Read More

Construct the derivation tree for the string aabbabba.

Bhanu Priya
Updated on 12-Jun-2021 09:31:05

10K+ Views

ProblemDerive a derivation tree for the string aabbabba for the given context free grammar (CFG) −S->aB|bA A->a|aS|bAA B->b|bS|aBBSolutionDerivation is a sequence of production rules, which is used to get input strings.Derivation treeIt is a graphical representation for derivation of given production rules for a given CFG. It is also called as a parse tree.PropertiesThe derivation tree contains some properties, which are as follows −The root node is always a node indicating the start symbol.The derivation is read from left to right.The leaf node is always terminal nodes.The interior nodes are always the non-terminal nodes.The given CFG is as follows −S->aB|bA ... Read More

Design finite automata from a given regular expression.

Bhanu Priya
Updated on 12-Jun-2021 09:27:47

2K+ Views

Finite automata (FA) is an abstract computing device. It can be represented in the following −Graphical (Transition diagrams)Tabular (Transition table)Mathematical (Transition function)The formal definition of FA is that it is a five tuples.M=(Q, Σ, δ, q0, F)Where, Q: Finite set called statesΣ: Finite set called alphabetsδ: Q × Σ → Q is the transition functionq0 ∈ Q is the start or initial stateF: Final or accept stateRegular expressionThe regular expression can be used to describe a sequence of patterns that defines a string. It is used to match character combinations in strings.The language accepted by some regular expression are referred ... Read More

Derive the string “abb” for leftmost and rightmost derivation

Bhanu Priya
Updated on 12-Jun-2021 09:24:35

2K+ Views

ProblemLet’s consider a grammar to derive “abb” string using LMD and RMD   S->AB/ ε   A-> aB   B-> SbSolutionWe have to use context free grammar.Derivation is a sequence of production rules, which is used to get input strings.During parsing, we have to take two decisions, which are as follows −We have to decide which non-terminal has to be replaced.We have to decide which non-terminal has to be replaced by using which production rule.There are two options to decide which non-terminal has to be replaced with production rule −Leftmost derivationRightmost derivationLeftmost derivationThe input is scanned and replaced with production rules from left ... Read More

How to generate the language for context free grammar?

Bhanu Priya
Updated on 12-Jun-2021 09:22:44

3K+ Views

ProblemGenerate the language for the given context free grammar.S->0S, S-> λS-> A0, A->1A, A-> λS->000S, S-> λSolutionContext free grammar (CFG) is a formal grammar that is used to generate all the possible patterns of strings in a given formal language.CFG is defined by four tuplesG=(V, T, P, S)Where, T: Set of terminals (lowercase letters) symbols.V: Vertices or non-terminal symbols (Capital letters).P: Production rules.S: Start symbol.Example 1The grammar is −S->0S, S->λCase 1 − S->0S     ->0Case 2 − S->0S    ->00S    ->00Case 3 − S->0S   ->00S   ->000S   ->000Therefore, the language generated for the given grammar is −L={e, 0, 00, 000……..}Example ... Read More

Advertisements