Question

In: Computer Science

a) Give 5 good examples of Regular language. b) Give 5 good examples of Regular Grammar.

a) Give 5 good examples of Regular language.

b) Give 5 good examples of Regular Grammar.

Solutions

Expert Solution

SOL:

a) 5 good examples of regular languages:

1) L={w| w ∈(a+b)* w starts with a}

This is a Regualar language which accepts set of all strings starts with a

L = {a,aa,ab,aab,....}

2) L = {w| w ∈ (a+b)* |w|%2 ==0}

This a Regular Language which accepts set of all strings whose length is divisible by 2

L = {ε,aa,ab,ba,bb,...}

3) L = {w | w ∈ (a+b)* na(w)=3 starts with b}

This is a regular language which accepts set of all strings which starts with b and contains exactly 3 a's

L = {baaa,babaa,...}

4) L = {w | w ∈ (a+b)* na(w)%2 ==0 and nb(w)%3==0}

This is a regular language which accepts set of all strings in which no of a's divisible by 2 and no of b's divisible by 3

L = {ε,aabbb,bbbaa,aaaabbb,....}

5) L = { w | w ∈ (a+b)* 2nd symbol from begining in w is b}

This is a regular language which accepts set of all strings in which second symbol from begining is b

L = {ab,bb,aba,abb,...}

b) 5 Good examples of Regular grammars:

1) S -> aA

A -> a | b | ε

This regular grammar generates set of all strings which starts with a

The strings generated by this grammar are L = {a,aa,ab,aab,....}

2) S -> aS | bS | a

This regular grammar generates set of all strings which ends with a

The strings generated by this grammar are L = {a,aa,ba,aaa,...}

3) S -> Aa | Ab

A -> Bb

B -> Ba | Bb | ε

This regular grammar generates set of strings in which second symbol is b or ending with ba or bb

L = {ba,bb,abb,aba,aba,...}

4) S -> Sa | Sb | A

A -> Bb

B -> Ba | Bb | ε

This regular grammar generates set of all strings which contains b

L = {b,ab,ba,bb,aab,aba,...}

5) S -> Sa | Sb | A

A -> Bbb | Baa

B -> Ba | Bb | ε

This regualar grammar generates set of all strings which contains either aa or bb

L = { aa,bb,abba,aaaa,...}


Related Solutions

5 Regular => Context-Free Give a proof by induction on regular expressions that: For any language...
5 Regular => Context-Free Give a proof by induction on regular expressions that: For any language A, if A is regular, then A is also context-free. You may assume that the statements from the previous Closure under Context-Free Languages problem are proved.
Construct an NPDA that accepts the language defined by the given grammar and give the language...
Construct an NPDA that accepts the language defined by the given grammar and give the language in a formal expression (including a regular expression). S -> AA|a, A-> SA|ab
Suppose A and B are regular language. Prove that AB is regular
Suppose A and B are regular language. Prove that AB is regular
Determine whether or not the following languages are regular. If the language is regular then give...
Determine whether or not the following languages are regular. If the language is regular then give an NFA or regular expression for the language. Otherwise, use the pumping lemma for regular languages or closure properties to prove the language is not regular. 1) L = { 0 n1 k : k ≤ n ≤ 2k} 2) L = { 0 n1 k : n > 0, k > 0 } È { 1 k0 n : k > 0, n...
Regular => Context-Free Give a proof by induction on regular expressions that: For any language A,...
Regular => Context-Free Give a proof by induction on regular expressions that: For any language A, if A is regular, then A is also context-free. You may assume that the statements from the previous Closure under Context-Free Languages problem are proved. R is a regular expression if RR is: a for some a∈alphabet Σ, the empty string ε, the empty set ∅, R​1​​∪R​2​​, sometimes written R​1​​∣R​2​​, where R​1​​ and R​2​​ are regular expressions, R​1​​∘R​2​​, sometimes written R​1​​R​2​​, where R​1​​ and...
Compare the language generated by Grammar #2 to the language generated by Grammar #1. How do...
Compare the language generated by Grammar #2 to the language generated by Grammar #1. How do the two languages compare to each other? (Is one language a proper subset of the other? Does each language contain a string that the other one does not? Do both grammars generate the very same language?) grammar #1 where S is the start symbol   S → tV | iC | iV | i C → tV V → iC | iV | i Grammar...
Give the finite-state automaton and the regular grammar for the following: (a) (ab v ba)* v...
Give the finite-state automaton and the regular grammar for the following: (a) (ab v ba)* v (ab)* (b) (11*)*(110 v 01) (c) All strings over {0,1} containing the string 010 (d) All strings over {0,1} which do not contain the string 010
Using the pumping lemma for regular languages, show that language is not regular. b) L3= {0n...
Using the pumping lemma for regular languages, show that language is not regular. b) L3= {0n 1m, m = n+2 } Language= {0,1}
Give a context-free grammar for {w ∈ {b, c}∗| #c(w) = #b(w)}.
Give a context-free grammar for {w ∈ {b, c}∗| #c(w) = #b(w)}.
Write a regular expression for the language of all strings over {a,b} in which every b...
Write a regular expression for the language of all strings over {a,b} in which every b is directly preceded by a, and may not be directly followed by more than two consecutive a symbols.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT