Found 345 Articles for Data Structure Algorithms

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

What are the regular expressions to finite automata?

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

719 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

What do you mean by ambiguity in grammar in TOC?

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

19K+ Views

A grammar is said to be ambiguous if there exists more than one left most derivation or more than one right most derivation or more than one parse tree for a given input string.If the grammar is not ambiguous then we call it unambiguous grammar.If the grammar has ambiguity then it is good for compiler construction.No method can automatically detect and remove the ambiguity, but we can remove the ambiguity by re-writing the whole grammar without ambiguity.ExampleLet us consider a grammar with production rules, as shown below −E = IE = E+EE = E*EE = (E)E = ε|0|1|2|3...9Let's consider a ... Read More

Explain Pumping lemma for context free language

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

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

Advertisements