- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 345 Articles for Data Structure Algorithms
393 Views
The star height of Regular expression (RE) is nothing but the depth of Kleene stars in the theory of computation (TOC).For example, a+b the star height is 0(a+b)* the star height is 1(a*+b*)* the star height is 2 …….Star height is used to indicate the structural complexity of regular languages and expressions.The regular expressions may have different star height that depends on structural complexity or nesting.The star height of a regular language is a unique number and that is equal to the least star height of any regular expression which represents that language.The star height of regular expressions is a ... Read More
3K+ Views
A grammar with at most one variable at the right side of production is called linear grammar.Following is an example of the linear grammar −S→aSb/εHere, if you observe, we can write the same production by dividing …..S→AbA→aAbA→εLeft Linear GrammarA grammar is left linear grammar where all non-terminals in the right hand sides are at the left end.For example, A→Sa/εSteps for conversionThe steps for the conversion of finite automata (FA) to the left linear grammar are as follows −Step 1 − Take reverse of the finite automataStep 2 − write right linear grammarStep 3 − Then take reverse of the right ... Read More
5K+ Views
A grammar with at most one variable at the right side of production is called linear grammar.Example 1 S→aSb/εExample 2 S→Ab A→aAb A→εRight Linear GrammarA grammar is right linear grammar where all the non terminals in the right hand sides are at the right end.For example, S->aS/εAlgorithm for conversionThe algorithm to convert the finite automata (FA) to the right linear grammar is as follows −Step 1 − Begin the process from the start state.Step 2 − Repeat the process for each state.Step 3 − Write the production as the ... Read More
4K+ Views
To identify whether a language is regular or not, is based on Pigeon Hole Principle. This is generally called as the Pumping Lemma.Pumping lemma for Regular languagesIt gives a method for pumping (generating) many substrings from a given string.In other words, we say it provides means to break a given long input string into several substrings.It gives the necessary condition(s) to prove a set of strings is not regular.But the pumping lemma is a contradiction test. This means if any language does not satisfy pumping lemma, then we can say that it is not regular. However, if it satisfies the ... Read More
24K+ Views
The Church-Turing thesis says that every solvable decision problem can be transformed into an equivalent Turing machine problem.It can be explained in two ways, as given below −The Church-Turing thesis for decision problems.The extended Church-Turing thesis for decision problems.Let us understand these two ways.The Church-Turing thesis for decision problemsThere is some effective procedure to solve any decision problem if and only if there is a Turing machine which halts for all input strings and solves the problem.The extended Church-Turing thesis for decision problemsA decision problem Q is said to be partially solvable if and only if there is a Turing ... Read More
870 Views
ProblemEliminate epsilon, unit and the useless symbols for the given grammar and rewrite it into CNF.S->0E0|1FF| εE->GF->S|EG->S| εSolutionIn the given grammar, we will first remove the null production. There are two null productions in the grammar, as given below −S ==> εG ==> εSo, remove null production and rewrite all the other rules containing G by epsilon there, along with old productions. We do not remove S ==> epsilon as it is the start symbol.Remove G ==> epsilon, we get the following −S ==> 0E0 | 1FF | εE ==> G | εF ==> S | EG ==> SNow remove ... Read More
835 Views
ProblemGenerate a Chomsky normal form (CNF) for the following context free grammar (CFG).S->aAa|bBb|eA->C|aB->C|bC->CDE|eD->A|B|abSolutionFollow the steps mentioned below to generate a CNF for the given CFGStep 1 − Eliminate ∧ -productionsWe can delete, erase or ∧ -productions double time repeated.S --> aAa | bBb | ∧A --> a | ∧B --> b | ∧D --> A | B | abStep 2 − Eliminate unit productions in above grammarEliminate R.H.S one symbol productionsS --> aDa | bDbD --> a | b | abStep 3 − Eliminate useless symbolsE is a useless symbol from given grammar since it is not derivative in RHS.S ... Read More
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
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
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