- 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 700 Articles for Computer Science
650 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
17K+ 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
21K+ 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
164 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
1K+ 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
34K+ Views
In an automata theory, there are different closure properties for regular languages. They are as follows −UnionIntersectionconcatenationKleene closureComplementLet see one by one with an exampleUnionIf L1 and If L2 are two regular languages, their union L1 U L2 will also be regular.ExampleL1 = {an | n > O} and L2 = {bn | n > O}L3 = L1 U L2 = {an U bn | n > O} is also regular.IntersectionIf L1 and If L2 are two regular languages, their intersection L1 ∩ L2 will also be regular.ExampleL1= {am bn | n > 0 and m > O} andL2= {am ... Read More
3K+ 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 −
4K+ Views
To convert the regular expression to Finite Automata (FA) we can use the Subset method.Subset method is used to obtain FA from the given regular expression (RE).Step 1 − Construct a Transition diagram for a given RE using Non-deterministic finite automata (NFA) with ε moves.Step 2 − Convert NFA with ε to NFA without ε.Step 3 − Convert the NFA to equivalent DFA.We will divide the given expression into three parts as follows −“1” ,”(0+1)*, and “0”NFA with Epsilon transition is as follows −Now, we will remove the epsilon transition.After removing, the transition diagram is given below −
6K+ Views
The regular expression R= a+ba* divided into r1 and r2r1= a and r2= ba*Let us draw Non-deterministic finite automata (NFA) for r1 as given below −Now, we will go for r2 = ba *Divide r2 into r3 and r4, where, r3=b and r4=a*The NFA for r3 is as follows −The NFA for r4 is as follows −q5 on epsilon movies goes to q6 and q8, q6 on ‘a’ goes to q7 whereas, q7 on epsilon moves goes to q6 as well as q7.r2= r3.r4Now, concatenate r3 and r4 as shown below −q3 on input ‘b’ goes to q4, q4 on ... Read More
1K+ Views
Induction is a powerful tool in mathematics. It is a way of proving propositions that hold for all natural numbers.Hypothesis − The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order to prove the first or initial statement. The initial statement is called Hypothesis.Suppose there exists a k > 0 such that for any regular expression r where 0 < OP(r) < k, there exists an NFA- s such that L(M) = L(r). Furthermore, suppose that M has exactly one final state.Inductive StepLet r be ... Read More