Found 690 Articles for Computer Science

Convert the given Context free grammar to CNF

Bhanu Priya
Updated on 12-Jun-2021 12:10:49

16K+ Views

ProblemConvert the given grammar into Chomsky's Normal Form (CNF)S->AAA|BA->aA|BB-> εSolutionFollow the steps given below to convert CFG to CNF −Step 1 − Eliminate epsilon productionsTo eliminate epsilon productions, the variable which is producing epsilon must be replaced on the RHS of all other productions for the epsilon production to be removed.Replacing B with ε in all other productions gives the following production set −S-> AAA | ε | BA->aA | ε | BReplacing A with \epsilon in all other productions gives the following −S ->AAA | AA | A | B | ε [replacing 1, 2, and 3 A's with ε ... Read More

Explain the removal of useless symbols

Bhanu Priya
Updated on 12-Jun-2021 12:06:25

5K+ Views

All grammars are not always optimized, which means the grammar may consist of some extra symbols (non-terminals) which increase the length of grammar.So, we have to reduce the grammar by removing such useless symbols.PropertiesThe properties to reduce grammar are explained below −Each non-terminal and terminal of G appears in the derivation of some word in LThere should not be any production as X->Y where X and Y are non-terminals.If epsilon is not in language L then, there need not be in the production X-> ε.The use of reducing grammar is as follows −DefinitionA symbol X is useful if there is ... Read More

Explain how to convert CFG to CNF

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

3K+ Views

CFG stands for context free grammar and CNF stands for Chomsky’s Normal Form in the theory of computation.Context Free Grammar (CFG)A context free grammar (CFG) is a forma grammar which is used to generate all possible patterns of strings in a given formal language.It is defined as four tuples −G=(V, T, P, S)Where, G is a grammar, which consists of a set of production rules. It is used to generate the strings of a language.T is the final set of terminal symbols. It is denoted by lower case letters.V is the final set of non-terminal symbols. It is denoted by ... Read More

Explain Chomsky normal form in TOC

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

9K+ Views

Chomsky’s Normal Form Stands as CNF.A context free grammar is in CNF, if the production rules satisfy one of the following conditionsIf there is start Symbol generating ε. Example − A-> εIf a non-terminal generates two non-terminals. Example − S->ABIf a non-terminal generates a terminal. Example − S->aExampleLet's take G1 Production rules, as given below −G1={ S->AB,          S->c,          A->a,          B->b}G1 satisfies the rule specified for CNF. So, it is in CNF.Now, let's consider G2 production rules, as shown belowG2={ S->aA,          A->a,       ... Read More

Explain the simplification of context free grammar in TOC

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

1K+ Views

A context free grammar (CFG) is a forma grammar which is used to generate all possible patterns of strings in a given formal language.It is defined as four tuples −G=(V, T, P, S)Where, G is a grammar, which consists of a set of production rules. It is used to generate the strings of a language.T is the final set of terminal symbols. It is denoted by lower case letters.V is the final set of non-terminal symbols. It is denoted by capital lettersP is a set of production rules, which is used for replacing non-terminal symbols (on the left side of ... Read More

What is the decision problem in TOC?

Bhanu Priya
Updated on 12-Jun-2021 11:47:52

2K+ Views

A decision problem Q is a set of questions, each having either yes or no answer. Let us consider the question is “is 10 a perfect square?” which is an example for a decision problem. A decision problem generally consists of an infinite number of related questions.ExampleThe problem PSQ which determines whether an arbitrary natural number is a perfect square or not having some doubtful questions like the following −q0: Is 0 a perfect square?q1: Is 1 a perfect square?q2: Is 2 a perfect square?SolutionA solution to a decision problem Q is an algorithm which determines the approximate answer to ... Read More

What is the Instantaneous description of PDA?

Bhanu Priya
Updated on 12-Jun-2021 11:45:25

11K+ Views

The Instantaneous description is called as an informal notation, and explains how a Push down automata (PDA) computes the given input string and makes a decision that the given string is accepted or rejected.The PDA involves both state and content of the stack.Stack is often one of the important parts of PDA at any time.So, we make a convenient notation for describing the successive configurations of PDA for string processing.The factors of PDA notation by triple (q, w, γ) wereq is the current state.w is the remaining input alphabet.γ is the current contents of the PDA stack.Generally, the leftmost symbol ... Read More

What is the difference between DFA and NFA?

Bhanu Priya
Updated on 31-Oct-2023 20:57:57

53K+ Views

DFA is the short form for the deterministic finite automata and NFA is for the Non-deterministic finite automata. Now, let us understand in detail about these two finite automata.DFAA Deterministic Finite automata is a five-tuple automata. Following is the definition of DFA −M=(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.NFANFA also has five states same as DFA, but with different transition function, as shown follows −δ: Q X Σ ... Read More

Explain the various applications of automata in TOC

Bhanu Priya
Updated on 04-Nov-2023 00:36:54

23K+ Views

Automaton is nothing but a machine which accepts the strings of a language L over an input alphabet Σ. There are four different types of Automata that are mostly used in the theory of computation (TOC). These are as follows − Finite-state machine (FSM). Pushdown automata (PDA). Linear-bounded automata (LBA). Turing machine (TM). When comparing these four types of automata, Finite-state machines are less powerful whereas Turing machines are more powerful. Note − Deterministic Finite Automata (DFA) and the Non-Deterministic Finite Automata (NFA) have the same power because every DFA ... Read More

What is unambiguous grammar in TOC?

Bhanu Priya
Updated on 12-Jun-2021 11:53:55

4K+ Views

A grammar can be unambiguous, if the grammar does not contain ambiguity. This means if it does not contain more than one left most derivation (LMD) or more than one right most derivation (RMD) or more than one parse tree for the given input string, it is an unambiguous grammar.RulesTo convert the ambiguous grammar to the unambiguous grammar, we apply the following rules −Rule 1 − If the left associative operators (+, -, *, /) are used in the production rule, then apply left recursion in the production rule. Left recursion is nothing but left most symbol on the right side ... Read More

Advertisements