Found 345 Articles for Data Structure Algorithms

Explain Type-1 grammar in TOC

Bhanu Priya
Updated on 16-Jun-2021 13:19:14

4K+ Views

Chomsky Hierarchy represents the class of languages that are accepted by the different machines.Chomsky hierarchyHierarchy of grammars according to Chomsky is explained below as per the grammar types −Type 0. Unrestricted grammars   Turing Machine (TM)Type 1. Context-sensitive grammars   Linear Bounded Automaton (LBA)Type 2. Context-free grammars   Pushdown Automaton (PDA)Type 3. Regular grammars   Finite Automaton (FA)Type-1 Context Sensitive Grammar (CSG)Type 1 grammar is also known as context sensitive grammarThe context sensitive grammar is used to represent context sensitive languageThe CSG follows some rules, which are as follows −The context sensitive grammar may have more than one symbol on the left hand side ... Read More

Explain Type-0 grammar in TOC

Bhanu Priya
Updated on 16-Jun-2021 13:18:29

9K+ Views

Chomsky Hierarchy represents the class of languages that are accepted by the different machines.Chomsky hierarchyHierarchy of grammars according to Chomsky is explained below as per the grammar types −Type 0. Unrestricted grammars   Turing Machine (TM)Type 1. Context-sensitive grammars   Linear Bounded Automaton (LBA)Type 2. Context-free grammars   Pushdown Automaton (PDA)Type 3. Regular grammars   Finite Automaton (FA)Type-0 unrestricted grammarType-0 grammars generate recursively enumerable.In type-0 the production has no restrictions.There may be any phase structure grammar which includes all formal grammarsThey generate the language which is recognized by the Turing machine.The productions can be in the form of a->b where, a is a string ... Read More

Explain Chomsky hierarchy in TOC

Bhanu Priya
Updated on 16-Jun-2021 13:17:35

10K+ Views

Chomsky Hierarchy represents the class of languages that are accepted by the different machines.Chomsky hierarchyHierarchy of grammars according to Chomsky is explained below as per the grammar types −Type 0 − It is an Unrestricted grammarsUnrestricted grammar − an unrestricted grammar is a 4-tuple (T, N, P, S), which consisting of −T = set of terminalsN = set of nonterminalP =as set of productions, of the form −v->wwhere v and w are strings consisting of nonterminal and terminals.S = is called the start symbol.Example − Turing Machine (TM)Type 1 − Context-sensitive grammarsAll productions are of form, v -> w where ... Read More

Explain the balancing parenthesis of PDA

Bhanu Priya
Updated on 16-Jun-2021 13:04:29

4K+ Views

Pushdown Automata (PDA) are the finite automata (FAs), but with the ability to push and pop symbols to/from a stack.PDA accepts strings if there is a legal path from start state to acceptance state for input. Otherwise, the string is rejected.A PDA can be represented by a 7-tuple(Q, ∑, ℾ, q0, ha, ∆, δ)WhereThe PDA is to finite subsets of Q ☓ (ℾ ∪ {∆})*.Parentheses are balanced ifWhile reading string, number of opening parentheses >= number of closing parentheses.When string is read, number of opening parentheses = number of closing parentheses.Examples(())() − Balanced((()() − Not balanced)()(() − Not balancedThe context ... Read More

What is Non deterministic finite automata?

Bhanu Priya
Updated on 16-Jun-2021 13:03:51

1K+ Views

For each state, there is exactly one transition corresponding to each symbol of the respective alphabet. This is termed as the Deterministic Finite Automaton (DFA)Nondeterministic Finite Automaton (NFA)For each state there can be zero, one, two, or more transitions corresponding to a particular symbol.If NFA gets to a state with more than one possible transition corresponding to the input symbol, we say it branches.If NFA gets to a state where there is no valid transition, then that branch dies An NFA accepts the input string if there exists some choice of transitions that leads to ending in an accept state.Thus, ... Read More

Construct Finite State Machine as Processing input

Bhanu Priya
Updated on 16-Jun-2021 13:03:02

347 Views

Finite automata is an abstract computing device. It is a mathematical model of a system with discrete inputs, outputs, states and a set of transitions from state to state that occurs on input symbols from the alphabet Σ.Formal definition of Finite AutomataFinite automata is defined as a 5-tuplesM=(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.Consider the Oyster card barriers at tube stations −States −ClosedOpenTransitions −Swipe cardEnter gateSuccess − Will ... Read More

Design a PDA which recognizes the language

Bhanu Priya
Updated on 16-Jun-2021 12:58:17

436 Views

ProblemGenerate the push down automata (PDA) that recognizes the language E={aibj| i is not equal to j and I is not equal to 2j}.SolutionConsider the two languages as given below −L1={aibj|i,j>=0 and i>2j}L2={aibj|i,j>=0 and iaA   A->aaAb|aA|epsilonIn L2, the number of a's are less than double the number of b'sSo the CFG for L2 becomes as follows −   S2->Bb|aBb   B->Bb|aBb|aaBb|epsilon   S->S1|S2L1: {aibj:i>2j}L2:{aibj: i

What are the Turing machine variations in TOC?

Bhanu Priya
Updated on 04-Nov-2023 01:36:28

30K+ Views

Turing machines (TM) can also be deterministic or non-deterministic, but this does not make them any more or less powerful.However, if the tape is restricted so that you can only see use of the part of the tape with the input, the TM becomes less powerful (linear bounded automata) and can only recognise context sensitive languages.Many other TM variations are equivalent to the original TM. This includes the following −Multi-trackMulti-tapeMulti-headMulti-dimensional tapeThe off-line Turing machineMulti-tape Turing MachineA Turing machine with several tapes we call it a multi tape Turing machine.Every tape’s have their own Read/Write headFor N-tape Turing MachineM={( Q, X, ... Read More

Explain removing unit productions in context free grammar

Bhanu Priya
Updated on 16-Jun-2021 12:56:04

15K+ 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 the 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 L.There 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 diagram given herewith describe the properties to reduce grammar −The unit productions are the productions ... Read More

Explain the elimination of epsilon productions in CFG

Bhanu Priya
Updated on 16-Jun-2021 12:38:15

7K+ 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 the 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 L.There 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 diagram given below depicts the use of reduce grammar−The productions of type S-> ε are ... Read More

Advertisements