Computer Science Articles - Page 50 of 62

Convert the given Context free grammar to CNF

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

26K+ 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 how to convert CFG to CNF

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

4K+ 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

What is the Instantaneous description of PDA?

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

16K+ 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

72K+ 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

What is unambiguous grammar in TOC?

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

6K+ 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

What are the regular expressions to finite automata?

Bhanu Priya
Updated on 12-Jun-2021 12:29:13

1K+ Views

For each of the following languages, draw the finite automata (FA) accepting it.{a, b}*{a}The language states that the automata accept the strings containing any number of a's and b's and finally ending in a.The finite state automaton for the language is as follows −{a, b}*{b, aa}{a, b*}The language states that the automata accept the strings starting and ending with any number of a's and b's and containing any of the substrings b and aa.The finite state automaton for the language is a follows −{bbb, baa}*{a}The language states that the automata accept the strings containing any number of bbb's and baa's ... Read More

Explain Pumping lemma for context free language

Bhanu Priya
Updated on 12-Jun-2021 11:46:19

41K+ Views

Pumping lemma for context free language (CFL) is used to prove that a language is not a Context free languageAssume L is context free languageThen there is a pumping length n such that any string w εL of length>=n can be written as follows −|w|>=nWe can break w into 5 strings, w=uvxyz, such as the ones given below|vxy| >=n|vy| # εFor all k>=0, the string uvkxyyz∈LThe steps to prove that the language is not a context free by using pumping lemma are explained below −Assume that L is context free.The pumping length is n.All strings longer than n can be ... Read More

Construct a pair of languages by using CFG

Bhanu Priya
Updated on 12-Jun-2021 11:41:32

294 Views

ProblemConsider the following context-free grammars (CFG) and find the pairs of languages which can be generated by Gl and G2 respectively.SolutionConsider the following CFG −G1 : S->aS|B , B->b l bBG2: S->aA | bB , A->aA| B | ε , B->bB | εNow, we can generate the language as follows. First consider G1 as shown belowConsider G1: S->aS|B             B->b|bB Using S->B          ->b b can be generated Using S->B          ->bB          ->bb bb can be generated Using S->aS          ->aB   ... Read More

Explain the relationship between grammar and language in TOC

Bhanu Priya
Updated on 12-Jun-2021 11:40:08

2K+ Views

In order to understand the relationship between the grammar and language in the theory of computation (TOC), let us understand what is language generated by grammar in TOC.Language generated by grammarThe grammar is S-> aSb| E.In this grammar, by using S-> E, we can generate E.Therefore, E is part of L(G).Similarly, by using S=>aSb=>ab, ab is generated.Similarly, aabb can also be generated.Therefore, the result is as follows −L(G) = {anbn, n>0}In language L(G) which is discussed above, the condition n =0 is taken to accept the epsilon.Consider the grammar given belowS -> aSa | bSb | a |bNow, let us ... Read More

Construct a Finite Automata for the regular expression ((a+b)(a+b))*.

Bhanu Priya
Updated on 12-Jun-2021 11:02:54

4K+ Views

The language for the given regular expression (RE) is as follows −L={ ε,aa,ab,ba,aaaa,………}ExampleLet the regular expression be ((a+b)(a+b))*(a+b).Construct the Finite automata for the given regular expression.First, generate the language for the given Regular Expression −L={a,d,aaa,bbb,abb,bab,bba,………..}This is the language of odd length stringsThe Finite Automata is as follows −

Advertisements