Name:
Student ID:
CS181 Spring 2012 Problem Set 5
Due Friday, May 18th, 11am in box D1, BH2432
Please write your name and student ID in the
spaces provided then attach this sheet to the
front of your solutions.
that would be great!
Always explain your a
CS181 Winter 2016 - Problem Set 1 Solutions
1. (15 points). A Tierce NFA is a NFA that accepts a word w if there exist computation
paths for w such that more than one-third of the ending states are accepting. In this
question, we will study the equivalenc
Name:
Student ID:
CS181 Spring 2011 Problem Set 8
Due Friday, June 8th, 11am in box D1, BH2432
Please write your name and student ID in the
spaces provided then attach this sheet to the front
of your solutions.
Always explain your answers. Begin your
an
CS 181 FINAL EXAM
SPRING 2015
NAME _
UCLA ID _
You have 3 hours to complete this exam. You may assume without proof any statement proved
in class.
(2 pts)
1
Give a high-level description of a Turing machine that computes the function f W 1 ! 1 given
2
by
HOMEWORK 5
1
Determine the equivalence classes of L for each of the following languages L:
a.
b.
c.
2
Use the Myhill-Nerode theorem to prove that the following languages are nonregular:
a.
b.
c.
3
L D fw W w begins with a 1 and ends with a 0g
L D fw W w c
CS 181 EXAM #3
SPRING 2015
NAME _
UCLA ID _
You have 90 minutes to complete this exam. You may assume without proof any statement
proved in class.
1
Consider the following context-free grammar:
S ! SS j T
T ! aT j aT b j ab j a:
(1 pts)
a. Describe the la
CS 181 - Winter 2006 Formal Languages
Problem Set #5 Due February 20, 2008
Problem 4.1. (10 points) Recall the shuffle operator from Homework 2. Prove or disprove: a. Context free languages are closed under shuffle. b. Let L be context free and R r
CS181 Spring 12 - (partial) Solutions to Problem Set 1
1. (a)
(b)
(c)
(d)
Counterexample: L1 = cfw_0, 1, L2 = cfw_1. Then (L1 L2 ) L1 = cfw_.
Counterexample: L = cfw_ . Then L = cfw_ . |L| = 1.
This is wrong as well: (L cfw_ ) , but L cfw_ .
/
Proof. Assu
CS181 Spring 12 - (partial) Solutions to Problem Set 5
1. Playing with CFGs (40 pts.)
(a) Give a CFG and provide a proof intuition for the language
L1 = cfw_0n 1m |n m + 2
Solution. The following CFG G1 works for L1 :
S 00BA
A 0A1 |
B 0B |
A proof involve
CS181 Spring 12 - (partial) Solutions to Problem Set 2
1. Formalizing DFSAs (20 pts.) Let LAP (n, m), n 0, m > 0 be the language
of strings over = cfw_a whose lengths are in an arithmetic progression. Formally,
LAP (n, m) = cfw_an+km | k 0. Give a formal
Solution to homework 3
1. A Regular Expression for addition! (30 pts.)
Solution.
We will construct a NFSA N that accepts ADD. N will have two states, one which remembers
that the carry bit is 1 while the other remembers that the carry bit is 0. When in st
Name:
Student ID:
Collaborators:
CS181 Winter 2015 Problem Set 5
Due Friday, March 6, 11:59pm
Please write your name, student ID, and the
names of anyone you collaborated with in
the spaces provided and attach this sheet to the
front of your solutions. I
Name:
Student ID:
CS181 Winter 2017 - Final
Due Friday, March 17, 7 PM
This exam is open-book and open-notes, but any materials not used in this course are prohibited,
including any material found on the internet. Collaboration is prohibited. Please avoi
Name:
Student ID:
Collaborators:
CS181 Winter 2015 Problem Set 4
Due Monday, February 23, 11:59pm
Please write your name, student ID, and the
names of anyone you collaborated with in
the spaces provided and attach this sheet to the
front of your solution
CS181 Winter 2015 - Problem Set #2 Solutions
1. (30 points) Prove that the following language is not regular without using pumping lemma
(but you can use the examples we showed in the class and the discussion section to be
irregular).
L = cfw_0a 1b : a, b
CS181 Winter 2015 - Problem Set 4 Solutions
1. (30 points) For this problem, we consider P DAs with multiple stacks.
(a) (15 points) Prove that a P DA with two stacks is strictly more powerful than a
P DA with one stack (i.e. two stack P DAs recognize a l
CS181 Winter 2015 - Problem Set #3 Solutions
1. (20 points) Consider a new binary operation
dened as follows: if A and B are
two languages, then A B = cfw_xy|x A, y B, and |x| = |y|. Give a proof sketch for
the following statement: If A and B are regular
CS181 Winter 2015 - Problem Set 1 Solutions
1. (10 points). Give a DFA for the language
L = cfw_x cfw_0, 1 | x interpreted as a binary number is divisible by 3.
As an example, the binary string 001011 translates to the decimal number 11 and is
thus not di
Name:
Student ID:
Collaborators:
CS181 Winter 2015 Problem Set 1
Due Friday, January 23, 11:59pm
Please write your name, student ID, and the
names of anyone you collaborated with in
the spaces provided and attach this sheet to the
front of your solutions
CS181 Winter 2017 - Problem Set 1 Solutions
1. (15 points). A Tierce NFA is a NFA that accepts a word w if there exist computation
paths for w such that more than one-third of the ending states are accepting. In this
question, we will study the equivalenc
MAY 1, 2013
CS 181 MIDTERM EXAM
(4 pts)
1 Draw a deterministic finite automaton for the language of binary strings in
which the number of zeroes and the number of ones are both even.
(4 pts)
2 Draw a nondeterministic finite automaton for .0 Y 1/ 01.011 Y
CS 181 FINAL EXAM
JUNE 10, 2013
You may assume without proof any statement proved in class or assigned as homework.
(4 pts)
1
Let k be a fixed positive integer. Construct the smallest possible DFA for the language
Lk D .0Y0k 1/ over the binary alphabet, a
CS 181 FINAL EXAM
SPRING 2014
NAME _
UCLA ID _
You have 3 hours to complete this exam. You may assume without proof any statement proved
in class.
(2 pts)
1
Give a simple verbal description of the function f W f0; 1g ! f0; 1g computed by the Turing
machin
CS 181 EXAM #1
FALL 2015
NAME _
UCLA ID _
You have 90 minutes to complete this exam. You may assume without proof any statement
proved in class.
1
Prove that the following languages are regular:
(2 pts)
a. binary strings that contain neither 010101 nor 00
CS 181 EXAM #2
FALL 2015
NAME _
UCLA ID _
You have 90 minutes to complete this exam. You may assume without proof any statement
proved in class.
1
Give a regular expression for each of the following languages:
(2 pts)
a. strings of length at most 2015 ove
CS 181 EXAM #3
FALL 2015
NAME _
UCLA ID _
You have 90 minutes to complete this exam. You may assume without proof any statement
proved in class.
1
Consider the context-free grammar
S ! SS j T
T ! aT b j ":
(1 pts)
a. Describe the language generated by thi
CS 181 FINAL EXAM
FALL 2015
NAME _
UCLA ID _
You have 3 hours to complete this exam. You may assume without proof any statement proved
in class.
(2 pts)
1
Describe the function f W f0; 1g ! f0; 1g computed by the Turing machine below.
0 ! 0; R
q0
1 ! 1; R
CS 181A EXAM #1
SPRING 2014
NAME _
UCLA ID _
You have 90 minutes to complete this exam. You may assume without proof any statement
proved in class.
(3 pts)
1
Give a simple verbal description of the language recognized by the following DFA.
1
0; 1
0
0
1
0
Name:
Student ID:
Collaborators:
CS181 Winter 2015 Problem Set 3
Due Monday, February 16, 11:59pm
Please write your name, student ID, and the
names of anyone you collaborated with in
the spaces provided and attach this sheet to the
front of your solution
Name:
Student ID:
Collaborators:
CS181 Winter 2015 Problem Set 2
Due Monday, February 2, 11:59pm
Please write your name, student ID, and the
names of anyone you collaborated with in
the spaces provided and attach this sheet to the
front of your solutions
CS 181 Homework 2
Regular and context-free languages
Due not later than Thursday, August 3, 2017
Problem 1. Minimize:
0,1
0
0
0,1
0
1
1
1
0
1
1
0
0
1
Problem 2. L = cfw_ anbmc 2(n + m); n 0, m 0
Find if L is
a) a regular language;
b) a context-free langu
CS 181 Homework 1
Finite Automata and Regular Languages
Due Thursday, July 20, 2017
1. Given NFA N
0,1
0
1
0,1
find the language L(N) and build DFA DN equivalent to N.
2. Build DFA D and NFA N such that L(D) = L(N), which consists of all binary strings
th
3.3
:
S->AC|B A->a B->aB|d C->c
ac(
AC B a)
S =>AC=>aC=> ac
S =>B =>aB=> ad
S->ACD A->a| C->c D->d
cd
S=>ACD
=>CD
A->a
A->
C->c
cd
1.
2.
FIRST FOLLOW
FIRST( )
S, A, B,C,D
BCD
bCD
S->AC|D
A->a|B
B->b
C->c
D->d
FIRST
3.4
3.4
3.4.4
1.
stmt if expr then stmt
| if expr then stmt else stmt
| other
if expr then stmt
else $
3.4
2.
stmt id (parameter_list) | expr := expr
parameter_list parameter_list, parameter
parameter
parameter id
expr id (expr_list) | id
expr