CISC 223 - Assignment 2 Solutions
Winter 2014
1. (a) Accepted: 1, 010, 111 (for example)
Not accepted: 0, 11, 110 (for example)
(b) The transition table:
0
1
-A |
A
B
B |
B
C
C |
A
B
(c) The language consists of all strings that have an odd number of 1s.

CISC 223 - Assignment 1 (Winter 2015)
Due: beginning of class (9:30 AM), Wednesday January 14
1. (3 marks) Let = cfw_0, 1 and consider languages A = cfw_10, 11, 1, B = cfw_01, 00, 0.
(a) Write down all strings over that have length at most two.
(b) Write

CISC 223 - Assignment 1 Solutions
Winter 2015
1. (a) , 0, 1, 00, 01, 10, 11
(b) A B = cfw_1001, 1000, 100, 1101, 1100, 110, 101, 10. The language A B consists of 8
strings. (100 has two dierent decompositions as a concatenation of strings from A
and B.)
(

CISC 223 - Assignment 4 Solutions
Winter 2014
1. Question 1 solution:
Stage 0: At the beginning we mark as distinguishable each pair where one component
is an accepting state and the other is not.
Stage 1: (3, 5) is not marked because on a we get (1,1)

1
Context-Free Languages
This material is described in Chapter 10 of the textbook.
Context-free grammars are the most widely used specication tool for the syntactic
structure of programming languages.
Context-free grammars are more powerful than state d

1
Introduction
The relationship between programs and formal languages provides an example of the impact
of theory on practice. Uses of formal theory include the following:
lexical and parsing stages of compiler construction
use of regular expressions in

1
Parsing
This material is covered in Chapter 11 of the textbook.
Parsing is the process of determining if a string of tokens can be generated by a
grammar.
Parsing in an important step in the compilation of programming languages. Two directions:
Attemp

CISC 223 - Assignment 2 Solutions
Winter 2015
1. (a) Some strings that are accepted include: 1, 111, 010, 01110, 00001
Some strings that are not accepted include: 0, 00, 01, 011, 0111
(b) The transition table:
0
1
-A |
C
B
B |
D
A
C |
A
D
D |
B
C
(c) The

CISC223, Winter 2015, Minimization of DFAs and nonregular languages
1
Nonregular languages and minimization of DFAs
While the regular languages have nice properties (as we have seen in the early part of the
course), unfortunately many languages that we en

1
Specifying Algorithms
We now continue with Part A of the textbook.
Specications describe transformations from input values to output values.
A program transforms input values to output values in a particular way.
A specication consists of the followin

1
State-transition diagrams
This material is from Chapter 8 in the textbook.
Example. An identier can be dened as a string of letters and digits that begins with a
letter.
Token letter stands for any of the symbols a, . . . , z, A, . . . , Z.
Token digi

1
Converting regular expressions to state diagrams and
vice versa
This material is from Chapter 9 in the textbook.
We show that regular expressions and state diagrams dene exactly the same class of languages. This fact is remarkable because supercially st

1
Verifying Algorithms
We continue the discussion how to validate correctness statements for the central programming language constructs. Next we consider loops, see Section 2.9 in the textbook.
The inference rule for while statements is:
I&B cfw_C I
I cf

1
Introduction
The relationship between programs and formal languages provides an example of the impat
of theory on pratie. Uses of formal theory inlude the following:
lexial and parsing stages of ompiler onstrution
use of regular expressions in text edit

CISC/CMPE 223 - Assignment 2 Solutions
Winter 2017
1. (a) Some strings that are aepted inlude: 1, 111, 010, 01110, 00001
Some strings that are not aepted inlude: 0, 00, 01, 011, 0111
(b) The transition table:
0
1
-A |
C
B
B |
D
A
C |
A
D
D |
B
C
() The la

CISC/CMPE 223 - Assignment 4 (Winter 2017)
Due: Thursday February 16 by 3:30 PM
(in the loked CISC 223 drop-o box on Goodwin 2nd oor)
Papers that have all the names and
student numbers written exatly as requested in the regulations (found at the end), wil

Application: DNA and protein sequence matching
0 Primary structure of proteins: sequence of amino acids.
20 different amino acids, encoded as one-letter symbols
0 DNA molecule: two strands made up of a sequence of nucleotides
bases: Adenine, Thymine, Cyto

CISC/CMPE 223 - Assignment 3 (Winter 2017)
Due: Thursday February 2 by 3:30 PM
(in the loked CISC 223 drop-o box on Goodwin 2nd oor)
Papers that have all the names and
student numbers written exatly as requested in the regulations (found at the end), will

CISC/CMPE 223 - Assignment 1 Solutions
Winter 2017
1. (a) A B = cfw_baab, baaa, baa, bbab, bbaa, bba, bab, ba. The language A B onsists of 8
strings. (baa has two dierent deompositions as a onatenation of strings from A
and B .)
(b) B A = cfw_abba, abbb,

1
Converting regular expressions to state diagrams and
vice versa
This material is from Chapter 9 in the textbook.
We show that regular expressions and state diagrams dene exatly the same lass of languages. This fat is remarkable beause superially state d

1
State-transition diagrams
This material is from Chapter 8 in the textbook.
Example.
An identier an be dened as a string of letters and digits that begins with a
letter.
Token letter stands for any of the symbols a, . . . , z, A, . . . , Z.
Token digit s

CISC/CMPE 223 - Assignment 3 Solutions
Winter 2017
1. The solution for Question 1 is given in Figure 1 (next page).
2. Question 2 solution: The state diagram has exatly one aepting state whih is not
the starting state. Hene no initial modiation of the sta

2- Um the W dmbed 1 he mm" (aubm mil-WWW WM 9 4. Using the tic method described in the course, convert the below nondetetministic
below nondeterministic state diagram into a deterministic state diagram Your answer I I I I I I
should indicate how the deter

CISC/CMPE 223 - Assignment 2 (Winter 2017)
Due: Thursday January 26 by 3:30 PM
(in the loked CISC 223 drop-o box on Goodwin 2nd oor)
Papers that have all the names and
student numbers written exatly as requested in the regulations (found at the end), will

CISC/CMPE-223, Winter 2017, Minimization of DFAs and nonregular languages
1
Nonregular languages and minimization of DFAs
While the regular languages have nie properties (as we have seen in the early part of the
ourse), unfortunately many languages that w

CISC 223 - Assignment 2 (Winter 2015)
Due: beginning of class (9:30 AM), Wednesday January 21
1. (3 marks) Let = cfw_0, 1 and consider the state-transition diagram given in Figure 1.
0
C
A
0
1
1
1
1
0
B
0
D
Figure 1: State-transition diagram for Question

CISC 223 - Assignment 3 (Winter 2015)
Due: beginning of class (9:30 AM), Wednesday January 28
1. (3 marks) Using the method described in Section 9.1 (and in class), convert the following
regular expression into a state diagram:
(01) (0 + (01) )
Your answe