Found 282 Articles for Data Structure Algorithms

Derive the string “00101” using LMD and RMD while using CFG

Bhanu Priya
Updated on 11-Jun-2021 13:14:42

11K+ Views

ProblemDerive the string"00101" for left most derivation (LMD) and right most derivation (RMD) using context free grammar (CFG).SolutionThe grammar is as follows −S->A1B A->0A| ε B->0B| 1B| εLeft Most derivation (LMD)In the left most derivation, the given input is scanned and then replaced with the production rule from left side to right. So, we have to read that input string from left to right.The grammar is as follows −S->A1B rule1 A->0A| ε rule 2 B->0B| 1B| ε rule 3Hence, the LMD will be as follows −S->A1B ->0A1B rule2 ->00A1B rule2 ->001B rule2 ->0010B rule3 ->00101B rule3 ->00101 rule3 Derived the ... Read More

Explain the concept of derivation in TOC

Bhanu Priya
Updated on 11-Jun-2021 13:17:30

7K+ Views

Derivation is a sequence of production rules. It is used to get input strings. During parsing, we have to take two decisions, which are as followsWe have to decide the non-terminal which is to be replaced.We have to decide the production rule by which the non-terminal will be replaced.Two options to decide which non-terminal has to be replaced with the production rule are as follows −Left most derivationRight most derivation.Let us understand these two options in detail.Left Most DerivationIn the leftmost derivation, the input is scanned and then replaced with the production rule from left side to right. So, we ... Read More

How to show that the regular language is closed under the complementary operation?

Bhanu Priya
Updated on 11-Jun-2021 13:00:00

4K+ Views

Closure property is a technique to understand the class of the resulting language when we are performing an operation on two languages of the same class.That means, suppose L1 and L2 belong to regular language and if regular language is closed under operation ∪, then L1∪L2 will be a Regular language. But if RL is not closed under ∩, that doesn't mean L1∩L2 won't be a RL.For a class to be closed under an operation, it has to hold true for all languages in that class. So, if a class is not closed under an operation, we cannot say anything ... Read More

Find the regular expression for the given Finite automata with state elimination method

Bhanu Priya
Updated on 11-Jun-2021 12:58:59

1K+ Views

ProblemGenerate RE for a given finite automata by using the state elimination method.SolutionThere are two methods for converting a Deterministic Finite Automata (DFA) to Regular expression (RE).Arden's Theorem Method.State Elimination Method.The given automata is as follows−Step 1Initial state is A that has an incoming edge.So, we have to create a new initial state qi as follows−Step 2Initial state is B that has an incoming edge.So, we have to create a new final state qf as given below−Step 3Now, try to eliminate all intermediate states one by one.First eliminate state AThere is a path from state qi to B via A.So, ... Read More

Generate a Regular Expression for a Finite Automata with state elimination method

Bhanu Priya
Updated on 11-Jun-2021 12:58:10

2K+ Views

ProblemGiven a Finite Automata, we need to convert the Finite Automata into equivalent Regular Expression using the State Elimination Method.Step 1 − Initial state q1 has incoming edge. So, create a new initial state qi.Step 2 − Final state q2 has outgoing edge. So, create a new final state.Step 3 − Start eliminating intermediate states one after another.If there is path going to qi to q2 via q1So after eliminating q1 we can connect a direct path from qi to q2 having costε .c*.a=c*aThere is a loop on q2 using state qiSo after eliminating state q1 we can draw a ... Read More

Explain the concept of state elimination method in TOC

Bhanu Priya
Updated on 11-Jun-2021 12:57:11

3K+ Views

There are two methods for converting a Deterministic Finite Automata (DFA) to Regular expression (RE). These methods are as follows −Arden's Theorem Method.State Elimination Method.Now, let us learn about the state elimination method used in TOC.State Elimination MethodStep 1Initial state of DFA does not have any incoming edge.If there exists any incoming edge to the initial state, then we need to create a new initial state which has no incoming edge to it.An example about the relation between incoming edge and initial state is given below−Step 2There must be only one final state in DFA.If there exist multiple final states ... Read More

Find out the Regular expression for the given finite automata

Bhanu Priya
Updated on 11-Jun-2021 12:56:01

5K+ Views

ProblemConstruct a regular expression for the given finite automata.SolutionStep 1 − Let us write down the equation.q1=q1a+ εq1 is the start state and ε will be added as the input a which is coming to q1 from q1.Hence, we writeState=source state of input * input coming to itStep 2 − Similarly, q2=q1b+q2bq3=q2aStep 3 − Let us simplify q1 first.q1=q1a+ εwe can re-write it as follows−q1= ε +q1aWhich is similar to R=Q+RP which has a solution as follows−R=QP*Step 4 − Assuming R=q1, Q= ε, P=aWe get q1 = ε.a* since ε.R=Rq1=a*Step 5 − Substituting values of q1 in q2 we get, ... Read More

Construct RE for given finite automata with Arden’s theorem

Bhanu Priya
Updated on 11-Jun-2021 13:24:54

1K+ Views

There are two methods for converting a Deterministic Finite Automata (DFA) to Regular expression (RE). These methods are as follows −Arden's Theorem Method.State Elimination Method.Let us understand the Arden's Theorem method in detail.Arden's TheoremLet P and Q be the two regular expressions.If P does not contain null string, then the following equation in R, viz R = Q + RP, Which has a unique solution by R = QP*Here, The finite automata (FA) does not have epsilon moves.It must have only initial state q1.Its states are q1, q2, q3, ....qn. The final state may be some qi where i QP* ... Read More

Explain Arden’s theorem to convert DFA to Regular Expression

Bhanu Priya
Updated on 11-Jun-2021 12:23:30

6K+ Views

There are two methods for converting a Deterministic Finite Automata (DFA) to Regular expression (RE). These methods are as follows −Arden's Theorem Method.State Elimination Method.Let us understand the Arden's Theorem method in detail.Arden's TheoremLet P and Q be the two regular expressions.If P does not contain null string, then the following equation in R, viz R = Q + RP, Which has a unique solution by R = QP*Here, The finite automata (FA) does not have epsilon moves.It must have only initial state q1.Its states are q1, q2, q3, ....qn. The final state may be some qi where iRead More

What are the fundamental concepts of TOC?

Bhanu Priya
Updated on 11-Jun-2021 13:21:08

11K+ Views

The basic definitions of the fundamental concepts in the Theory of Computation (TOC) along with the relevant examples are explained below −SymbolSymbols simply call it as a character.It is an atomic unit, such as a digit, character, lowercase letter, etc. Sometimes it is also a word. The formal language does not deal with the “meaning” of the symbols.For example, a, b, c, ……………z0, 1, 2, …………..9+, -, *, %, …………special characters.AlphabetThe set of characters is called as the alphabet.An alphabet is a finite, non-empty set of symbols. It is denoted by Σ or E.For example, Σ ={0, 1} set of ... Read More

Advertisements