Found 690 Articles for Computer Science

What is a context sensitive language in TOC?

Bhanu Priya
Updated on 15-Jun-2021 13:21:25

4K+ Views

A context-sensitive grammar whose productions are of the formαAβ → αγβWhere α, β ∈ (N ∪ T)*, A ∈ N; γ ∈ (N ∪ T)+ and a rule of the form S → λ is allowed if the start symbol S do not appear on the right hand side of any rule.The language generated by such a grammar is called a context-sensitive language.Every context-free grammar is also context-sensitive =⇒ the context-free languages are a subset of the context-sensitive languages (see Chomsky Normal Form).But, not every context-sensitive language is context-free.ExampleThe language {anbncn, n > 1} is context-sensitive but not context free.A ... Read More

What are the restrictions of regular grammar?

Bhanu Priya
Updated on 15-Jun-2021 13:11:38

706 Views

A regular grammar is the one where each production takes one of the following restricted forms −B → ∧, B → w, B → A, B → wA.(Where A, B are non-terminals and w is a non-empty string of terminals.)Restrictions of regular grammarOnly one nonterminal can appear on the right-hand side of a production.Nonterminal must appear on the right end of the right-hand side.Therefore, the productions are as follows −A → aBc and S → TUThese are not part of a regular grammar, but the production A → abcA is.Things like A → aB|cC are allowed because they are actually ... Read More

Design a DFA that accepts at most 3 a"s

Bhanu Priya
Updated on 15-Jun-2021 12:51:13

12K+ Views

Construct deterministic finite automata that accepts at most 3 a’s over an alphabet ∑={a,b}.At most 3 a’s means,The string contains 0 to max 3 a’s and any number of b’s.L= {Є,a,aa,aaa,ab,abb,bab,bbabaa, bbabaabbb,…..}Construct DFALet’s construct DFA step by step −Step 1Valid inputs − aaa, a, aa,ε .Step 2Valid inputs − b, ba, baa, baaa, bb, bba, bbba,…Step 3Valid input − bab, abba, abbbaa, babba,…Step 4Valid inputs − babab, aabb, aaba, bbbaaba, …Step 5Valid inputs − aaabbb, aaabab, baaaba, …Step 6InValid inputs − aaaa, aaabab, baaaba,

Explain about CYK Algorithm for Context Free Grammar

Bhanu Priya
Updated on 15-Jun-2021 12:48:06

7K+ Views

CKY means Cocke-Kasami-Younger. It is one of the earliest recognition and parsing algorithms. The standard version of CKY can only recognize languages defined by context-free grammars in Chomsky Normal Form (CNF).It is also possible to extend the CKY algorithm to handle some grammars which are not in CNF (Hard to understand).Based on a “dynamic programming” approach −Build solutions compositionally from sub-solutionsIt uses the grammar directly.AlgorithmBegin    for ( i = 1 to n do )    Vi1 { A | A → a is a production where i th symbol of x is a }    for ( j = ... Read More

What are the properties of Regular expressions in TOC?

Bhanu Priya
Updated on 15-Jun-2021 13:00:04

7K+ Views

A regular expression is basically a shorthand way of showing how a regular language is built from the base set of regular languages.The symbols are identical which are used to construct the languages, and any given expression that has a language closely associated with it.For each regular expression E, there is a regular language L(E).There are some general equalities for the regular expressions.PropertiesAll the properties held for any regular expressions R, E, F and can be verified by using properties of languages and sets.Additive (+) propertiesThe additive properties of regular expressions are as follows −R + E = E + ... Read More

Design a DFA accepting stringw so that the second symbol is zero and fourth is 1

Bhanu Priya
Updated on 15-Jun-2021 12:45:14

2K+ Views

ProblemConstruct DFA which accepts a string that contains second symbol is zero and fourth symbol is 1 over an alphabet ∑={0,1}.SolutionInput − 00110Output is accepted; because in the given string the second symbol is ‘0’ and the fourth symbol is ‘1’.Input − 11001Output − string is not accepted, because the second symbol is not ‘0’.Design DFA step by step as given below −Step 1 -Valid inputs − 0001Step 2 -Valid input − 1001Step 3 -Valid inputs − 0011, 1011Step 4 -Valid inputs − 00010, 10010, 00110, 00011, 10011, 00111, …Step 5 -Invalid inputs − 0101, 0100, 0010, 1100, 0000, 1000, …Step 6 -Valid inputs − 01010, 01000, 11111, 0100000, …

Explain the intersection process of two DFA’s

Bhanu Priya
Updated on 15-Jun-2021 12:41:39

3K+ Views

According to the theorem, If L and M are two regular languages, then L ∩ M is also regular language.ExampleConstruct A∩B where A and B is given as follows −The language A ={10, 100, 00, 001, 1010, …..}The language B ={01, 1010, 10, 101, …..}AA = (QA, Σ, δA, qa, FA) AB = (QB, Σ, δB, qB, FB) A∩B=(QA x QB ,Σ, δ(qA x qB ,FA x F B )Where, δ(( p, q), a) =δL (p, a), δM (q, a))Here, QA x QB = {p, q} x {r, s}    ={(p, r), (p, s), (q, r), (q, s)} Z = ... Read More

Design a DFA accepting a language L having number of zeros in multiples of 3

Bhanu Priya
Updated on 15-Jun-2021 12:39:28

2K+ Views

ProblemConstruct a deterministic finite automata (DFA) that accepts a language L which has the number of zero’s is of multiple of 3 over an alphabet ∑=”{0,1}.SolutionIf input is: 000 Output is: string is acceptedBecause here the number of zero’s is multiple of 3.Designing DFAIn order to construct the DFA, follow the below mentioned steps −Step 1 -Valid inputs: 000, 000000, 09 , 012 , …Step 2 -Valid inputs: 1, 1000, 100000, …Step 3 -Valid inputs: 10100, 11000, 101100, …Step 4 -101010, 1101010, 1101110110, …Invalid inputs − 0,00,10000,01011, …

Construct DFA beginning with ‘a’ but does not have substring ‘aab’

Bhanu Priya
Updated on 15-Jun-2021 12:37:02

808 Views

ProblemGiven language to construct the deterministic finite automata (DFA) is, the strings start with ‘a’ but not contain substring ‘aab’ over alphabet ∑={a,b}.SolutionIf the input is: “baabba”The output is: string is not acceptedBecause the string does not start with ‘a’, and generating a substring ‘abb’,DFA transition diagramThe DFA transition diagram for the string beginning with ‘a’ but not having the substring as ‘aab’ is as follows −Transition tableThe transition table is as follows −STATEINPUT (a)INPUT (b)→ 01*4 (dead state)1*2*3*2*2*4 (dead state)3*1*3*4 (dead state)4 (dead state)4 (dead State)

Prove that the polynomial time reduction is from the Clique problem to the Vertex Cover problem

Bhanu Priya
Updated on 15-Jun-2021 12:30:04

2K+ Views

Vertex cover is a subset of vertices that covers all the edges in a graph. It is used to determine whether a given graph has a 3SAT to vertex cover.Clique is called a subset of vertices that are all directly connected. It determines whether a clique of size k exists in a graph.To prove − Vertex cover can be reduced to clique.ProofGiven a graph G=(V, E) and integer k.Get its complement graph G'=(V, E').Solve CLIQUE(G', |V|-k).If there is a solution, return yes. Otherwise, it returns as no.To prove this reduction, we need to show the following −If there is a ... Read More

Advertisements