
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 282 Articles for Data Structure Algorithms

899 Views
Here CFL refers to Context Free Language. Now, let us understand closure under concatenation.Closure under ConcatenationsIf L1 and L2 are CFLs, then L1L2 is a CFL.Follow the steps given below −L1 CFL implies that L1 has CFG1 that generates it.Assume that the nonterminals in CFG1 are S, A, B, C, . . ..Change the nonterminal in CFG1 to S1, A1, B1, C1, . . ..Don’t change the terminals in the CFG1.L2 CFL implies that L2 has CFG2 that generates it.Assume that the nonterminals in CFG2 are S, A, B, C, . . ..Change the nonterminal in CFG2 to S2, A2, ... Read More

748 Views
If L1 and L2 are CFLs, then their union L1 + L2 is a CFL.Here CFL refers to Context Free Language.L1 CFL implies that L1 has a CFG, let it is CFG1, that generates it.Assume that the nonterminals in CFG1 are S, A, B, C, . . ..Change the nonterminal in CFG1 to S1, A1, B1, C1, . . ..Don’t change the terminals in the CFG1.L2 CFL implies that L2 has a CFG, Let it is CFG2, that generates it.Assume that the nonterminals in CFG2 are S, A, B, C, . . ..Change the nonterminal in CFG2 to S2, A2, ... Read More

7K+ Views
A context-free grammar is a quadruple G = (N, T, P, S), Where, N is a finite set of nonterminal symbols, T is a finite set of terminal symbols, N ∩ T = ∅, P is a finite set of productions of the form A → α, Where A ∈ N, α ∈ (N ∪ T)*, S is the start symbol, S ∈ N.Construct a Context free grammar for the language, L = {anbm| m ≠n}Case 1n > m − We generate a string with an equal number of a’s and b’s and add extra a’s on the left −S ... Read More

4K+ Views
A Turing machine (TM) can be formally described as seven tuples −(Q, X, ∑, δ, q0, B, F)Where, Q is a finite set of states.X is the tape alphabet.∑ is the input alphabet.δ is a transition function:δ𝛿:QxX->QxXx{left shift, right shift}.q0 is the initial state.B is the blank symbol.F is the final state.A Turing machine T recognises a string x (over ∑) if and only when T starts in the initial position and x is written on the tape, T halts in a final state.T is said to recognize a language A, if x is recognised by T and if and ... Read More

501 Views
A Deterministic Finite automata (DFA) is a five 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.Let’s see the worst case number of states in DFA for the language A∩B and A*Let A and B be the two states, |A| = number of states = nA|B| = number of states = nBDFA = |A∩B| =nA.nB|A ∪ B| =nA.nB|A*|=3/4 2nA|AB| = nA (2nB-2nB-1)NFAThe non-deterministic finite automata (NFA) also have five states ... Read More

7K+ Views
The Chomsky hierarchy is given below −Type 2 − Context Free Grammar (CFG)Type 2 grammars are generated by context free languages.The language that is generated by the grammar is recognized by Push Down Automata.Type 2 must be in Type 1.Left-hand side of production can have only one variable.|alpha| =1There is no restriction on beta.The production rules are in the form of −A->alphaWhere, A is any single non-terminal and is any combination of terminals and nonterminals.ExampleS->ABA->aB->bType 3 − Regular grammarType 3 grammars are generated by regular languages.These languages are exactly all those languages that can be accepted by finite state automata.Type ... Read More

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

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

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

469 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