CS 337 - Theory in Programming Practice
Homework 9 & Exam 3 Review
Show all work. The logic you use to develop your solution is most important.
1. Compute the failure array for search pattern p = aabacabaab.
2. Carry out the KMP algorithm with p = aabacab
CS 337
Open book and notes.
Max points = 50
Test 2
4/5/06
Time = 50 min
Do all questions.
1. (Finite State Machine; 20 points) The nite state machine in Figure 1
compares the magnitudes of two binary strings of equal length. The machine is fed the bits al
CS 337
Open book and notes.
Max points = 50
Test 3
5/5/06
Time = 50 min
Do all questions.
1. (Relational Algebra; 15 points)
(a) (5 points) You are given relations CT and CR in Table 1 and Table 2
respectively. Compute their (natural) join, CT
CR.
(b) (5
CS 337
Open book and notes.
Max points = 75
Test 1
2/21/07
Time = 75 min
Do all questions.
1. (Compression; 28 points)
(a) (6 points) Create a Human tree for symbols with the following frequencies: cfw_12, 8, 20, 6, 32, 4, 20, 24.
(b) (16 points) A sender
CS 337
Open book and notes.
Max points = 75
Test 2
4/4/07
Time = 75 min
Do all questions.
1. (Finite State Machine; 15 points)
(a) A turnstile is either locked or unlocked. When the turnstile is locked,
a customer can drop a coin into its slot. This cause
CS 337
Test 3
Open book and notes.
Do all questions from Part 3 for Test 3 (75 points).
Bonus questions for Tests 1 and 2 appear on the last page.
5/10/07
Time = 105 min
1. (PART 3: Proofs of Recursive Programs; 15 points) Consider the following functions
CS 337
Open book and notes.
Pop Quiz 1
2/4/09
Problem Variables x and y are 4-bit long words in the following two equations.
Solve for x and y . Recall that x is the complement of x.
x y = 1,
y = x y,
1
CS 337
Open book and notes.
Pop Quiz 2
3/11/09
Problem Draw a nite state machine that accepts a string of digits s where either (1)
s is empty, or (2) s is a single digit at most 3, or (3) sum of every pair of adjacent digits
in s is at most 3. So, 2, 103
CS 337
Open book and notes.
Pop Quiz 3
3/30/09
Problem Write a Haskell program that takes a list of booleans as inputs and outputs
the same list retaining only its True entries.
Solution
trueretain [] = []
trueretain (x:xs)
|x
= x : (trueretain xs)
| othe
CS 337
Open book and notes.
Pop Quiz 4
4/20/09
Problem Let t be the string abba. What is the largest i such that ci (t20 ) = ? Justify.
Solution First, let us solve the problem for any n instead of 20. Observe c(tn ) =
tn1 , for n > 1. Hence, cn1 (tn ) =
CS 337
Open book and notes.
Max points = 75
Test 1
2/23/09
Time = 75 min
Do all questions.
1. (Compression; 30 points)
(a) (8 points) Given below is a Human tree over a set of symbols. Assign probabilities to the symbols. Note that the answer is not uniqu
CS 337
Open book and notes.
Max points = 75
Test 2
Time = 75 min
4/6/09
Do all questions.
1. (Finite State Machine Design; 15 points)
(a) (7 points) Design a nite state machine to accept a binary string
which does not contain three consecutive identical s
CS 337
Open book and notes.
Max points = 50
Test 1
Time = 50 min
2/20/06
Do all questions.
1. (Compression; 14 points)
(a) (6 points) Create a Human tree for symbols with the following frequencies: cfw_6, 4, 10, 3, 16, 2, 10, 12.
(b) (8 points) A sender s
CS 337 - Theory in Programming Practice
Homework 1 Solutions
1. Consider
symbol
a
b
c
the following
probability
.1
.7
.2
codes:
code 1
0
1
10
code 2 code 3
10
1
0
01
11
00
Which of these codes are prex codes? And which are not? Justify your answers.
Code
CS 337 - Theory in Programming Practice
Homework 2
Show all work. The logic you use to develop your solution is most important.
1. Exercise 4, #1 in textbook (p. 17)
a complete binary tree
2. Exercise 4, #3 in textbook (p. 18)
This is a lemma which is pro
CS 337 - Theory in Programming Practice
Homework 6
Show all work. The logic you use to develop your solution is most important.
1. Exercise 42, chapter 4
1. The rst two languages only contain . The last three languages are the empty
language.
2. cfw_, , ,
CS 337 - Theory in Programming Practice
Homework 5 Solutions
1. Construct DFAs for the following languages.
(a) The set of all bit strings containing substring 00 and ending with 01.
1
0
1
1
0
0
2
3
1
4
0
0
1
5
1
(b) The set of all bit strings with 3 cons
CS 337 - Theory in Programming Practice
Homework 4
Show all work. The logic you use to develop your solution is most important.
1. Carry out encryption and decryption on message M = 5 using RSA, given p = 3, q = 11
and e = 7.
So n = pq = 33, and (n) = 2(1
CS 337 - Theory in Programming Practice
Homework 3
Show all work. The logic you use to develop your solution is most important.
Use complete English sentences. A sequence of unconnected mathematical expressions does
not constitute a proof. Clearly state y
CS 337 - Theory in Programming Practice
Homework 2
Show all work. The logic you use to develop your solution is most important.
1. Exercise 4, #1 in textbook (p. 17)
a complete binary tree
2. Exercise 4, #3 in textbook (p. 18)
This is a lemma which is pro
CS 337 - Theory in Programming Practice
Homework 1 Solutions
1. Consider
symbol
a
b
c
the following
probability
.1
.7
.2
codes:
code 1
0
1
10
code 2 code 3
10
1
0
01
11
00
Which of these codes are prex codes? And which are not? Justify your answers.
Code
CS 337 - Theory in Programming Practice
Homework 9 & Exam 3 Review
Show all work. The logic you use to develop your solution is most important.
1. Compute the failure array for search pattern p = aabacabaab.
2. Carry out the KMP algorithm with p = aabacab
CS 337 - Theory in Programming Practice
Homework 6
Show all work. The logic you use to develop your solution is most important.
1. Exercise 42, chapter 4
1. The rst two languages only contain . The last three languages are the empty
language.
2. cfw_, , ,
CS 337 - Theory in Programming Practice
Homework 5 Solutions
1. Construct DFAs for the following languages.
(a) The set of all bit strings containing substring 00 and ending with 01.
1
0
1
1
0
0
2
3
1
4
0
0
1
5
1
(b) The set of all bit strings with 3 cons
CS 337 - Theory in Programming Practice
Homework 4
Show all work. The logic you use to develop your solution is most important.
1. Carry out encryption and decryption on message M = 5 using RSA, given p = 3, q = 11
and e = 7.
So n = pq = 33, and (n) = 2(1
CS 337 - Theory in Programming Practice
Homework 3
Show all work. The logic you use to develop your solution is most important.
Use complete English sentences. A sequence of unconnected mathematical expressions does
not constitute a proof. Clearly state y
CS 337
Open book and notes.
Max points = 75
Test 3
5/15/09
Time = 75 min
Do all questions.
1. (Relational Databases; 15 points) You are given relations SL (denoting Stores and Locations),
IT (Items and Types) and SIP (Stores, Items and Prices) in Table 1,