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
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...
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
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.
Form fits function. Give three good examples (a, b, c as specified below) of how the...
Form fits function. Give three good examples (a, b, c as specified below) of how the form or structure of a component fits its function in the cell. Clearly state the name and function of your chosen component and explain how form and function are related. a) Must be a small molecule or coenzyme: b) Must be a protein: c) Must be a multi-subunit macromolecular complex or organelle:
Detection Risk explain and give 5 examples? Define Brainstorming session and give 5 examples ?
Detection Risk explain and give 5 examples? Define Brainstorming session and give 5 examples ?
1. Consider the regular grammar G given below: S → aS|aA|bB|λ A → aA|bS B →...
1. Consider the regular grammar G given below: S → aS|aA|bB|λ A → aA|bS B → bB|aS (a) Give a derivation for the strings aabbba and baaba (b) Give an infinite language L such that L is not a subset of L(G) (c) Give a regular expression that describes the language L(G).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT