Found 345 Articles for Data Structure Algorithms

Explain NFA with epsilon transition.

Bhanu Priya
Updated on 12-Jun-2021 09:20:10

21K+ Views

We extend the class of NFAs by allowing instantaneous ε transitions −The automaton may be allowed to change its state without reading the input symbol 2.In diagrams, such transitions are depicted by labeling the appropriate arcs with ε.Note that this does not mean that E has become an input symbol. On the contrary, we assume that the symbol E does not belong to any alphabet.ε -NFAs add a convenient feature but (in a sense) they bring us nothing new. They do not extend the class of languages that can be represented.Both NFAs and E-NFAs recognize exactly the same languages.Epsilon (ε) ... Read More

Explain with an example how to convert NFA to DFA.

Bhanu Priya
Updated on 12-Jun-2021 09:17:08

2K+ Views

ProblemConvert the following Non-Deterministic Finite Automata (NFA) to Deterministic Finite Automata (DFA).SolutionThe transition diagram is as follows −The transition table of NFA is as follows −Stateab->q0q0q0, q1q1-*q2*q2--The DFA table cannot have multiple states. So, make q0q1 as a single state.Let’s convert the given NFA to DFA by considering two states as a single state.The transition table of DFA is as follows −Stateab->q0q0[q0, q1][q0q1][q0][q0q1q2]*[q0q1q2][q0][q0q1q2]In the above transition table, q2 is the final state. Wherever, q2 is present that becomes the final state.Note −After conversion the number of states in the final DFA may or may not be the same as in ... Read More

How to convert from NFA to DFA in TOC?

Bhanu Priya
Updated on 12-Jun-2021 09:14:20

2K+ Views

In Non-Deterministic Finite Automata, for any current state and input symbol, there exists more than one next output state.Any string is accepted if and only if there exists at least one transition path which is starting at initial state and ending at final state.The following steps are followed to convert a given NFA to a DFA −AlgorithmStep-01Let's take ' q’ as a new set of states of the DFA. It is declared null in the beginning.Let's take T’ be a new transition table of the DFA.Step-02Add the start state of the NFA to q’.Add transitions from the start state to ... Read More

Design a Moore machine for some binary input sequence.

Bhanu Priya
Updated on 12-Jun-2021 09:12:34

11K+ Views

ProblemDesign a Moore machine for a binary input sequence such that if it has a substring 101, the machine outputs A, if the input has substring 110, it outputs B otherwise it outputs C.SolutionFor designing such a machine, we will check two conditions, and those are 101 and 110. If we get 101, the output will be A, and if we recognize 110, the output will be B. For other strings, the output will be C.Moore machine has 6 tuples(Q, q0, Σ, O, δ, λ)Where, Q: Finite set of statesq0: Initial state of machineΣ: Finite set of input symbolsO: Output ... Read More

Design a Moore machine to generate 1's complement of a binary number.

Bhanu Priya
Updated on 12-Jun-2021 09:08:25

6K+ Views

Moore machine has 6 tuples, which are as follows −(Q, q0, Σ, O, δ, λ)Where, Q: Finite set of statesq0: Initial state of machineΣ: Finite set of input symbolsO: Output alphabetδ: Transition function where Q × Σ → Qλ: Output function where Q → OThe transition diagram is as follows −ExplanationStep 1 − q0 is the start state on input ‘0’ goes to q1 state and on ‘1’ goes to state q2 generating output 0.Step 2 − q1 on input ‘0’ goes to q1 itself and on ‘1’ goes to q2 generating output ‘1’.Step 3 − q2 on input ‘0’ ... Read More

Draw DFA which accepts the string starting with ‘ab’.

Bhanu Priya
Updated on 11-Jun-2021 14:39:49

20K+ Views

ProblemDraw the state transition diagram over an alphabet Σ={a, b} that accepts the string starting with ‘ab’.SolutionThe formal definition of Deterministic Finite Automata (DFA) is as follows −A DFA is a collection of 5-tuples as shown below −M=(Q, Σ, δ, q0, F)Where, Q: Finite set called states.Σ: Finite set called alphabets.δ: Q × Σ → Q is the transition function.q0 ∈ Q is the initial state.The language is generated as given below −L={ab, aba, abab, …….}The transition diagram is as follows −Here, D is a dead state.D is a transition state, which it can never escape. Such a state is ... Read More

What is a Moore Machine in TOC?

Bhanu Priya
Updated on 11-Jun-2021 14:31:25

3K+ Views

Moore machine is a finite state machine in which the next state is decided by the current state and the current input symbol.The output symbol at a given time depends only on the present state of the machine.The Moore machine has 6 tuples(Q, q0, Σ, O, δ, λ)Where, Q: Finite set of statesq0: Initial state of machineΣ: Finite set of input symbolsO: Output alphabetδ: Transition function where Q × Σ → Qλ: Output function where Q → OThe state diagram is as follows −Example 1Input − 010Transition − δ (q0, 0) => δ(q1, 1) => δ(q1, 0) => q2Output − ... Read More

What is a mealy machine in TOC?

Bhanu Priya
Updated on 11-Jun-2021 14:20:54

3K+ Views

In a mealy machine, the output symbol depends upon the present input symbol and on the present state of the machine.The output is represented with each input symbol and each state is separated by /.The mealy machine can be described by 6 tuples(Q, q0, Σ, O, δ, λ')Where, Q: Finite set of statesq0: Initial state of machineΣ: Finite set of input alphabetO: Output alphabetδ: Transition function, where Q × Σ → Qλ': Output function, where Q × Σ →OThe length of output for a mealy machine is equal to the length of input.Example 1Input − 11Transition −  δ (q0, 11)=> δ(q2, 1)=>q2Output − 00 (q0 to q2 transition has Output 0 and q2 to ... Read More

Design NFA with Σ = {0, 1} and accept all string of length at least 2.

Bhanu Priya
Updated on 11-Jun-2021 14:03:26

15K+ Views

Non-deterministic finite automata also have five states which are same as DFA, but with different transition function, as shown follows −δ: Q X Σ -> 2QNon-deterministic finite automata is defined as a 5 tuple, M=(Q, Σ, δ, q0, F)Where, Q: Finite set of statesΣ: Finite set of the input symbolq0: Initial stateF: Final stateδ: Transition function: Q X Σ -> 2QProblemDesign a transition diagram and table for the given language that accepts all strings of length at least 2.SolutionBefore proceeding to the solution, let’s understand what do you mean by length of string and how to find the length of ... Read More

Explain Non-Deterministic Finite Automata in TOC.

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

17K+ Views

NFA stands for non-deterministic finite automata. It is easy to construct an NFA when compared to DFA for a given regular language.The finite automata are called NFA when there exist many paths for specific input from the current state to the next state.Each NFA can be translated into DFA but every NFA is Non DFA.NFA is defined in the same way as DFA but with the following two exceptions, which are as follows −It contains multiple next states.It contains ε transitions.ExampleThe transition diagram is as follows −In the above NFA, it is clear that there exist many paths for specific ... Read More

Advertisements