Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. Write regular expressions for each of the following languages. = { 0, 1 } All

ID: 3813666 • Letter: #

Question

. Write regular expressions for each of the following languages.

= { 0, 1 } All strings that …

a, start with ‘0’

b, end with ‘11’

c, are not empty

d, do not contain ‘0’

e, have exactly two ‘0’s

f, alternate zeros and ones (starting with either) and are not empty

g, have length at most 4

h,start with ‘0’ and are at least length two, or start with ‘1’ and end with ‘1’

i, are in reverse numeric order (all ‘1’s, if any, precede all ‘0’s, if any) and have length at least two

l, have 0 in the second or third position, but not both, and have length at least four

Explanation / Answer

Scan string from left to right
First input is 'a' and follow the rule:
on input 'a' and STACK alphabet Z, push the input 'a' into STACK as : (a,Z/aZ) and state are q0
Second input is 'a' then follow the rule:
on input 'a' and STACK alphabet 'a', push the input 'a' into STACK as : (a,a/aa) and state are q0
Third input is 'b' then follow the rule:
on input 'b' and STACK alphabet 'a', push the input 'b' into STACK as : (b,a/ba) and state are q0
Fourth input is 'b' then follow the rule:
on input 'b' and STACK alphabet 'b', push the input 'b' into STACK as : (b,b/bb) and state are q0
Fifth input is 'c' then follow the rule:
on input 'c' and STACK alphabet 'b' and state is q0, pop one 'b' as : (c,b/) and state are q1
Sixth input is 'c' and prime of STACK is 'b' therefore follow the rule:
on input 'c' and STACK alphabet 'b' and state is q1, pop one 'b' as : (c,b/) and state stay q1
Seventh input is 'c' and prime of STACK is 'a' therefore follow the rule:
on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/) and state are q1
Eighth input is 'c' and prime of STACK is 'a' therefore follow the rule:
on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/) and state are stay q1
We reached finish of the string, therefore follow the rule:
on input and STACK alphabet Z, attend final state(qf) as : (, Z/Z)Scan string from left to right
First input is 'a' and follow the rule:
on input 'a' and STACK alphabet Z, push the input 'a' into STACK as : (a,Z/aZ) and state are q0
Second input is 'a' then follow the rule:
on input 'a' and STACK alphabet 'a', push the input 'a' into STACK as : (a,a/aa) and state are q0
Third input is 'b' then follow the rule:
on input 'b' and STACK alphabet 'a', push the input 'b' into STACK as : (b,a/ba) and state are q0
Fourth input is 'b' then follow the rule:
on input 'b' and STACK alphabet 'b', push the input 'b' into STACK as : (b,b/bb) and state are q0
Fifth input is 'c' then follow the rule:
on input 'c' and STACK alphabet 'b' and state is q0, pop one 'b' as : (c,b/) and state are q1
Sixth input is 'c' and prime of STACK is 'b' therefore follow the rule:
on input 'c' and STACK alphabet 'b' and state is q1, pop one 'b' as : (c,b/) and state stay q1
Seventh input is 'c' and prime of STACK is 'a' therefore follow the rule:
on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/) and state are q1
Eighth input is 'c' and prime of STACK is 'a' therefore follow the rule:
on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/) and state are stay q1
We reached finish of the string, therefore follow the rule:
on input and STACK alphabet Z, attend final state(qf) as : (, Z/Z)Scan string from left to right
First input is 'a' and follow the rule:
on input 'a' and STACK alphabet Z, push the input 'a' into STACK as : (a,Z/aZ) and state are q0
Second input is 'a' then follow the rule:
on input 'a' and STACK alphabet 'a', push the input 'a' into STACK as : (a,a/aa) and state are q0
Third input is 'b' then follow the rule:
on input 'b' and STACK alphabet 'a', push the input 'b' into STACK as : (b,a/ba) and state are q0
Fourth input is 'b' then follow the rule:
on input 'b' and STACK alphabet 'b', push the input 'b' into STACK as : (b,b/bb) and state are q0
Fifth input is 'c' then follow the rule:
on input 'c' and STACK alphabet 'b' and state is q0, pop one 'b' as : (c,b/) and state are q1
Sixth input is 'c' and prime of STACK is 'b' therefore follow the rule:
on input 'c' and STACK alphabet 'b' and state is q1, pop one 'b' as : (c,b/) and state stay q1
Seventh input is 'c' and prime of STACK is 'a' therefore follow the rule:
on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/) and state are q1
Eighth input is 'c' and prime of STACK is 'a' therefore follow the rule:
on input 'c' and STACK alphabet 'a' and state is q1, pop one 'a' as : (c,a/) and state are stay q1
We reached finish of the string, therefore follow the rule:
on input and STACK alphabet Z, attend final state(qf) as : (, Z/Z)