CS 374
Lab 17 April 3
Spring 2015
1. Design a one-tape TM that computes the function f (x) = 2x. More specically, when started
in the initial state scanning the rst 0 in a block of x consecutive 0s (i.e., the Instantaneous
Description (or ID) at the begin
CS 374
Lab 16 April 1
Spring 2015
Suppose we are given both an undirected graph G with weighted edges and a minimum spanning tree T
of G.
1. Describe an efcient algorithm to update the minimum spanning tree when the weight of one
edge e T is decreased.
2.
CS 374
Lab 6 February 11
Spring 2015
Give context-free grammars for each of the following languages. For each grammar, describe in English
the language for each non-terminal, and in the examples above. As usual, we wont get to all of these in
section. Ski
CS 374
Lab 5 February 6
Spring 2015
Prove that each of the following languages is not regular.
1. Binary palindromes: Strings over cfw_0, 1 that are equal to their reversals. For example: 00111100
and 0100010, but not 01100.
2. cfw_02n 1n | n 0
3. cfw_0m
CS 374
Lab 2 January 28
Spring 2015
This lab gives practice at constructing DFAs.
1. Design a DFA that accepts all strings over the alphabet cfw_$,0,1,2,3,4,5,6,7,8,9,. that correspond
to valid currency amounts. A valid string is either a dollar sign foll
CS 374
Lab 0 January 21
Spring 2015
1. Suppose you have a rectangular bar of chocolate, which has been scored into an n m grid of
squares. Consider breaking the chocolate into squares in the following way. In each round you
take one of the available piece
Turing Machines & Computability
Course Trajectory
Seen lots of algorithms, what can be done.
Interested in limita2ons (algorithmic; @me)
Need more precise [email protected] of
what is a computer / [email protected]
what does p
Algorithms
Lecture 20: Minimum Spanning Trees [Fa14]
We must all hang together, gentlemen, or else we shall most assuredly hang
separately.
Benjamin Franklin, at the signing of the
Declaration of Independence (July 4, 1776)
It is a very sad thing that no
CS 374: Algorithms & Models of Computation,
Spring 2015
Greedy Algorithms for
Minimum Spanning Trees
Lecture 18
March 31, 2015
Chandra & Lenny (UIUC)
CS374
1
Spring 2015
1 / 61
Part I
Greedy Algorithms: Minimum
Spanning Tree
Chandra & Lenny (UIUC)
CS374
2
CS 374: Algorithms & Models of Computation,
Spring 2015
Dynamic Programming:
Shortest Paths and DFA to
Reg Exps
Lecture 16
March 17, 2015
Chandra & Lenny (UIUC)
CS374
1
Spring 2015
1 / 54
Part I
Shortest Paths with Negative Length
Edges
Chandra & Lenny (U
Nondeterminis+c Finite Automata
DFA Reminder
A DFA is a quintuple M=(Q,q0,F), where:
Q is a nite set of states
is a nite alphabet of symbols
: Q x Q is a transi+on func+on
q0 is the ini+al state
F
Strings, Languages, and
Regular expressions
Deni&ons for strings
= nite alphabet of symbols
= cfw_0,1, or =cfw_a,b,c,.,z, or =all ascii characters
string or word = nite sequence of symbols of
length of
Determinis)c Finite Automata
DFAs (also called FSMs)
A simple(st?) model of what a computer is
Many devices modeled, programmed as DFAs
Vending machines
Elevators
Digital watch logic
Calculators
Lexical anal
Regular Expressions & Automata
Regular Language Equivalence Thm
Languages captured by DFAs, NFAs, and regular
expressions are the same.
DFAs
Proof:
NFAs
today
regular
expressions
Regular expression NFA Theorem
I
Closure Proper+es
of Regular Languages
Closure proper*es
In general, if S is a set, and foo() is a binary
operator dened on elements of S, then we
say S is closed under foo i for any pair of
elements s, t
CS 374
Lab 3 January 30
Spring 2015
This lab gives practice at constructing NFAs and understanding their power and exibility.
1. Design an NFA for the set of strings that consist of 01 repeated one or more times, or 010 repeated
one or more times.
2. Let
CS 374
Lab 1 January 23
Spring 2015
This lab is about strings and regular expressions. Recall the denition and properties of the
concatenation operator between strings.
Lemma 1: Concatenating nothing does nothing: For every string w, we have w = w.
Lemma