0% found this document useful (0 votes)
21 views10 pages

Midterm Solution

Uploaded by

1roebot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views10 pages

Midterm Solution

Uploaded by

1roebot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Question 1

Correct
3.00 points out of 3.00

Flag question

Question text

Match the context-free grammars to their corresponding regular expressions.

S -> SSSSS | a
a(aaaaa)*
Answer 1

S -> SaS |b b(ab)*


Answer 2
S -> aT | bT | λ
((a + b) (a + b))*
T -> aS | bS Answer 3
Feedback

Your answer is correct.


The correct answer is: S -> SSSSS | a → a(aaaaa)*, S -> SaS |b → b(ab)*, S -> aT | bT | λ
T -> aS | bS → ((a + b) (a + b))*
Question 2
Correct
1.00 points out of 1.00

Flag question

Question text

Find the regular expression of the language of all strings that do not end with bc over {b,c}.
Select one:
a. (b + c)*(bb + cc + cb)*
b. (b + c)*(b + c)+
c. None of the options.
d. (b + c)*
e. (b + c)*(bb + cc + cb)
Correct!
Feedback

Your answer is correct.


The correct answer is: (b + c)*(bb + cc + cb)
Question 3
Correct
1.00 points out of 1.00

Flag question

Question text

Find the regular expression for the following language over {a, b} with strings containing at least
two a's.
Select one:
a. (a+b)+a(a+b)+a(a+b)+
b. (a+b)*a(a+b)*a(a+b)*
Correct!

c. (a+b)*(a+b)*(a+b)*
d. (a+b)+(a+b)+
e. b*a*b*a*

f. (a+b)+ (a+b)+ (a+b)+


Feedback

Your answer is correct.


The correct answer is: (a+b)*a(a+b)*a(a+b)*

Question 4
Partially correct
4.00 points out of 5.00

Flag question

Question text

Match the following machines with the description of the machine or the language it accepts.
Your answer is partially correct.
You have correctly selected 4.
The correct answer is:
→ An NFA that accepts the language
defined by: (0 U 1)*01(011 U 0*)11*.,

→ Binary strings in which

there is a pair of 0s separated by a number of positions that is a multiple of 4.,


The complement of the language containing at most one occurrence of the substring 00.,

→ All binary strings with the property that in every prefix, the number of 0s and the number of 1s
differ by at most 2.,
→ Binary strings in which the number of 0s and the number of 1s is both even.

Question 5
Correct
1.00 points out of 1.00

Flag question

Question text

Which simple description correctly describes the language recognized by the following DFA?
Select one:
a. All binary strings of length 12 that contains the substring 1111
b. None of the options.
c. All binary strings that contain 0010 but not 00010
d. All binary strings that contain 0010
Correct!

e. Only strings that contain 0110110 but not 0010


Feedback

Your answer is correct.


The correct answer is: All binary strings that contain 0010

Question 6
Correct
1.00 points out of 1.00

Flag question

Question text

Find the s-grammar for L={0n1n : n >= 2}.


Select one:
a. S -> 0T
T -> 0AB
A -> 0AB | 1
B -> 1

Correct!

b. S -> 0TB
T -> 0ABB
A -> 0ABB | 1
B -> 1

c. S -> 0T
T -> 0AB
A -> 0AB | 1
B -> 1 | λ

Feedback

Your answer is correct.


The correct answer is: S -> 0T
T -> 0AB
A -> 0AB | 1
B -> 1

Question 7
Correct
1.00 points out of 1.00

Flag question

Question text

There exists a nonregular language L such that L* is regular.


Select one:
True

False
Feedback

Correct! The nonregular language L = {anbn} over {a,b} is not regular, but L* = {a, b}* is regular.
The correct answer is 'True'.

Question 8
Correct
1.00 points out of 1.00

Flag question

Question text

Which strings are not accepted by the following DFA?


Select one:
a. 1110001110000111100010101
Correct. The DFA accepts binary strings where the number of 0s is a multiple of 5. This string
does not conform to those constraints.

b. 1000111001010001110111010010100110110101011
c. 0011101011011111
d. 11100011100001111000

e. 0101010101
Feedback

Your answer is correct.


The correct answer is: 1110001110000111100010101

Question 9
Incorrect
0.00 points out of 1.00

Flag question

Question text

Find the regular expression for the language which contains strings containing
both aba and bab as substrings over {a,b}.
Select one:
a. (a+b)* ((aba (a+b)* bab) + (bab (a+b)* aba))+ (a+b)*
Incorrect. Does not allow for the strings abab or baba.

b. (a+b)* ((aba (a+b)* bab) + (bab (a+b)* aba) + abab + baba) + (a+b)*
c. (a+b)*(aba)*(bab)*(a+b)*
d. (a+b)*((aba (a+b)* bab))+ (a+b)*

e. None of the options.


Feedback

Your answer is incorrect.


The correct answer is: (a+b)* ((aba (a+b)* bab) + (bab (a+b)* aba) + abab + baba) + (a+b)*

Question 10
Correct
1.00 points out of 1.00

Flag question

Question text

Find the regular expression for the language of strings not containing aaa over {a,b}.
Select one:
a. None of the options.
b. b* (a + aa + λ)
c. (a+b)*(ab+ + aab+)* (a + aa + λ)
d. b*(ab+ + aab+)* (a + aa + λ)
Correct!

e. b*(ab+ + aab+)*
Feedback

Your answer is correct.


The correct answer is: b*(ab+ + aab+)* (a + aa + λ)

You might also like