quiz1-example-soln-fall09

quiz1-example-soln-fall09 - 1 1 1 4 2 3 0 | 01 | 011 or 0(...

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

View Full Document Right Arrow Icon
CMSC330 Example Quiz #1 Solution 1. (6 pts) Programming languages Name a disadvantage of dynamic types in terms of program correctness. Provide a code example in Ruby showing the disadvantage. Type errors are not caught at compile time. For example, in the following code: x = 4 x = “a” if ( … ) x = x / 2 x = “a” is not a compile-time error. The error is hidden until x = x/2 is executed at run time. 2. (4 pts) Ruby features What is the output (if any) of the following Ruby programs? Write FAIL if code does not execute. a. a = [ ] // nil b 3 a[1] = “b” a[2] = 3 a.each{ |x| puts x } 3. (4 pts) Regular expressions and finite automata Give a regular expression equivalent to the following finite automaton.
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: 1 1 1 4 2 3 0 | 01 | 011 or 0( & | 1 | 11) 4. (6 pts) Regular expression to NFA Create a NFA for the regular expression a|(bc)* using construction method from class. c 1 2 a 4 5 3 b 6 9 10 8 7 5. (10 pts) NFA to DFA Apply the subset construction algorithm to convert the following NFA to a DFA. Be sure to list the NFA states represented by each DFA state. 1 2 3 a 4 5 6 b 7 8 1,3,4 5,7,8 1,2 4,8 6,8 a b a...
View Full Document

Page1 / 2

quiz1-example-soln-fall09 - 1 1 1 4 2 3 0 | 01 | 011 or 0(...

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