quiz2-fall10

quiz2-fall10 - a = [1,2,3] # Output = b = a.collect { |x|...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CMSC330 Fall 2010 Quiz #2 Name Discussion Time (circle one): 9am 10am 11am 12pm 1pm 2pm Instructions Do not start this test until you are told to do so! You have 15 minutes for this quiz. This is a closed book exam. No notes or other aids are allowed. Answer essay questions concisely in 2-3 sentences. Longer answers are not needed. For partial credit, show all of your work and clearly indicate your answers. Write neatly. Credit cannot be given for illegible answers. 1. (2 pts) What is the output (if any) of the following Ruby program? Write FAIL if code does not execute. Recall that Array.collect applies a code block to each element of an array, and creates a new array from the value returned by the code block.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a = [1,2,3] # Output = b = a.collect { |x| #{x-1}! } puts b 2. (6 pts) Consider the regular expression ab*. Recall * has higher precedence than concatenation. a. (1 pt) Does it accept the string a? Circle one: Yes No b. (5 pts) Create a NFA for ab*, using the algorithm discussed in class. 3. (12pts) Consider the following NFA. 1 3 2 & 4 a & a b a. (2 pts) Does it accept the string aa? List a possible sequence of state transitions (e.g., 1,3,4) leading to acceptance / rejection of aa. b. (10 pts) Convert the NFA to a DFA using the subset construction algorithm discussed in class. Be sure to label each state in the DFA with the corresponding state(s) in the NFA....
View Full Document

This note was uploaded on 01/13/2012 for the course CMSC 330 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 2

quiz2-fall10 - a = [1,2,3] # Output = b = a.collect { |x|...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online