0% found this document useful (0 votes)
79 views

RegEx and FSM Questions

The document contains questions about regular expressions and finite state machines. It has 4 sets of questions - converting between FSMs and regexes, describing languages of regexes, and determining what strings are accepted by regexes. The questions test understanding of basic regex patterns and concepts.

Uploaded by

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

RegEx and FSM Questions

The document contains questions about regular expressions and finite state machines. It has 4 sets of questions - converting between FSMs and regexes, describing languages of regexes, and determining what strings are accepted by regexes. The questions test understanding of basic regex patterns and concepts.

Uploaded by

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

RegEx and FSM questions and answers: Name:

______________

Question Set 1: From Finite State Machines to Regular Expressions – write the Regular Expression
FSM to Regex Questions:
1. FSM Description: Accepts binary strings ending in "01".
 Answer:
2. FSM Description: Accepts strings containing exactly one "a" followed by any number of "b"s.
 Answer:
3. FSM Description: Accepts strings of "a"s and "b"s where "a" must not be followed directly by "b".
 Answer:
4. FSM Description: Accepts strings that start with an "a" followed by zero or more "b"s, and ends with "c".
 Answer:
5. FSM Description: Accepts strings where "a" occurs at least once, and after every "a" there is at least one "b".
 Answer:

Question Set 2: From Regular Expressions to Finite State Machines – draw or describe the FSM
Regex to FSM Questions:
EXAMPLE
Regular Expression: 1*0
Answer: An FSM with an initial state that loops on "1", a transition on "0", and then reaches a final state.

1. Regular Expression: (01|10)*


 Answer:
2. Regular Expression: ab*a
 Answer:
3. Regular Expression: (a|b)*abb
 Answer:
4. Regular Expression: (0|1)*0
 Answer:

1
Question Set 3: Describe the Accepted Language – describe the language accepted by the regular expression.
Regular Expression Descriptions:
Example
Regular Expression: (a|b)*
Description: Accepts any sequence of "a"s and "b"s, including the empty string.

1. Regular Expression: a+b+


 Description:
2. Regular Expression: 1(01*0)*1
 Description:
3. Regular Expression: (ab|cd)+
 Description:
4. Regular Expression: 0*1(01*0)*
 Description:

Question Set 4: String Acceptance by Regular Expressions – state the strings which would be accepted by the
regular expression.
Regular Expression String Acceptance Questions:
1. Regular Expression: a*b*
 Strings: "aaaa", "bbbb", "abab", "aaabb", ""
 Accepted Strings:
2. Regular Expression: (0|1)*01
 Strings: "0101", "1100", "001", "1001", "1111"
 Accepted Strings:
3. Regular Expression: (a|b)+
 Strings: "a", "b", "ab", "ba", "aaa", "bb", "abc"
 Accepted Strings:
4. Regular Expression: ab?a
 Strings: "aba", "aa", "abba", "ab", "a"
 Accepted Strings:
5. Regular Expression: 1*0+1?
 Strings: "1110", "0001", "01", "0", "111001"
 Accepted Strings:

You might also like