Quiz Stuff

Quiz 9, March 26, 2018
3 minutes; 1 + 1 + ½ + ½ points; 3 points total

  1. What's the length of the shortest and longest strings described by the following RE?
       /(a|bb|[a-z][1-3])/
  2. What is the value of each of the following Ruby expressions?
       /@/ =~ "ab@cd"
       /..@../ =~ "ab@cd"
  3. Write a RE that will match four character strings whose first and last characters are x and whose middle two characters are digits.
  4. In computer science theory, a language is a set of ______________.

EC ½ point: How many levels does the Chomsky Hierarchy of languages have?

EC ½ point: Tell me something about regular expressions not evidenced above.

Answers

  1. What's the length of the shortest and longest strings described by the following RE?
       /(a|bb|[a-z][1-3])/
    Shortest is 1; longest is 2.
  2. What is the value of each of the following Ruby expressions?
       /@/ =~ "ab@cd" => 2
       /..@../ =~ "ab@cd" => 0
  3. Write a RE that will match four character strings whose first and last characters are x and whose middle two characters are digits.
    /x\d\dx/
  4. In computer science theory, a language is a set of   strings  .

EC ½ point: How many levels does the Chomsky Hierarchy of languages have?

4

EC ½ point: Tell me something about regular expressions not evidenced above.

A regular expression specifies a regular language.