CS 124
Lecture 22
Spring 2011
Suffix trees are an old data structure that have become new again, thanks to a recent new linear time algorithm
for constructing suffix trees due to Ukkonen that proves more useful for many applications. Here, we will describ
Lecture 11
CS 124
11.1 Applications: Fingerprinting for pattern matching
Suppose we are trying to find a pattern string P in a long document D. How can we do it quickly and efficiently?
Hash the pattern P into say a 16 bit value. Now, run through the file
CS124
Lecture 8
Spring 2011
Divide and Conquer
We have seen one general paradigm for finding algorithms: the greedy approach. We now consider another
general paradigm, known as divide and conquer.
We have already seen an example of divide and conquer algo
Lecture 10
CS124
Spring 2011
10.1 The Birthday Paradox
How many people do there need to be in a room before with probability greater than 1/2 some two of them have the
same birthday? (Assume birthdays are distributed uniformly at random.)
Surprisingly, on
Lecture 7
CS124
In todays lecture we will be looking a bit more closely at the Greedy approach to designing algorithms. As we
will see, sometimes it works, and sometimes even when it doesnt, it can provide a useful result.
Horn Formulae
A simple applicati
CS124
Lecture 5
Spring 2011
Minimum Spanning Trees
A tree is an undirected graph which is connected and acyclic. It is easy to show that if graph G(V, E) that
satisfies any two of the following properties also satisfies the third, and is therefore a tree:
CS124
Lecture 6
Spring 2011
Disjoint set (Union-Find)
For Kruskals algorithm for the minimum spanning tree problem, we found that we needed a data structure for
maintaining a collection of disjoint sets. That is, we need a data structure that can handle t
Tossing a Biased Coin
Michael Mitzenmacher
When we talk about a coin toss, we think of it as unbiased: with probability one-half it comes up heads,
and with probability one-half it comes up tails. An ideal unbiased coin might not correctly model a real
co
Unbiasing Random Bits
Michael Mitzenmacher
1. Introduction
Most computers use a pseudo-random number generator in order to mimic
random numbers. While such pseudo-random numbers are sufficient for
many applications, they may not do in cases where more sec
Lecture 12
CS124
12.1 Near duplicate documents1
Suppose we are designing a major search engine. We would like to avoid answering user queries with multiple
copies of the same page. That is, there may be several pages with exactly the same text. These dupl
Lecture 14
14-6
Multiplying both sides by 11 , 21 , . . . , (p 1)1 we have
1 = a p1 mod p.
This proves Claim 5.
We now return to the end of Claim 4, where we must prove
x1+k(p1)(q1) = x mod n.
We first claim that x1+k(p1)(q1) = x mod p. This is clearly tr
CS124
Lecture 9
Spring 2010
9.1 The String reconstruction problem
The greedy approach doesnt always work, as we have seen. It lacks flexibility; if at some point, it makes a wrong
choice, it becomes stuck.
For example, consider the problem of string recon
CS 124
Lecture 21
We now consider a natural problem that arises in many applications, particularly in conjunction with suffix
trees, which we will study later. Suppose we have a rooted tree T with n nodes. We would like to be able to answer
questions of t
Lecture 20
CS124
Heuristics can be useful in practice, but sometimes we would like to have guarantees. Approximation algorithms
give guarantees. It is worth keeping in mind that sometimes approximation algorithms do not always perform as well
as heuristic
CS124
NP-Completeness Review
Where We Are Headed
Up to this point, we have generally assumed that if we were given a problem, we could find a way to solve
it. Unfortunately, as most of you know, there are many fundamental problems for which we have no eff
CS124
Lecture 19
We have defined the class of NP-complete problems, which have the property that if there is a polynomial time
algorithm for any one of these problems, there is a polynomial time algorithm for all of them. Unfortunately, nobody
has found a
CS124
Lecture 17
Network Flows
Suppose that we are given the network in top of Figure 17.1, where the numbers indicate capacities, that is, the
amount of flow that can go through the edge in unit time. We wish to find the maximum amount of flow that can g
Lecture 16
16-10
max-flow problem as well that improve on this running time.
To summarize: the max-flow problem can be easily reduced to linear programming and solved by simplex. But
it is easier to understand what simplex would do by following its iterat
CS124
15.1
Lecture 15
2SAT
We begin by showing yet another possible way to solve the 2SAT problem. Recall that the input to 2SAT is a logical
expression that is the conjunction (AND) of a set of clauses, where each clause is the disjunction (OR) of two li
Lecture 13
CS124
Hopefully the ideas we saw in our hashing problems have convinced you that randomness is a useful tool in
the design and analysis of algorithms. Just to make sure, we will consider several more example of how to use
randomness to design a
CS124
Lecture 3
Spring 2011
Graphs and modeling
Formulating a simple, precise specification of a computational problem is often a prerequisite to writing a
computer program for solving the problem. Many computational problems are best stated in terms of g
CS124
Lecture 4
Spring 2011
Breadth-First Search
A searching technique with different properties than DFS is Breadth-First Search (BFS). While DFS used an
implicit stack, BFS uses an explicit queue structure in determining the order in which vertices are
CS124Spring, 2017
Homework 7
Out: April 10, 2017
Due: April 23, 2017 (4:59pm)
1. If we restrict the problems we look at, sometimes hard problems like counting the number of independent sets
are in a graph become solvable. For instance, consider a graph th
CS124Spring, 2017
Homework 4
Out: Feb 24, 2017
Due: March 3, 2017 (4:59 pm)
For all homework problems where you are asked to give an algorithm, you must prove the correctness of your algorithm
and establish the best upper bound that you can give for the r
600.363/463 Algorithms - Fall 2013
Solution to Assignment 9
(50 points)
34.2-1 Consider the language GRAPH-ISOMORPHISM= cfw_hG
1, G2i : G1 and G2 are isomorphic
graphs.Prove that GRAPH-ISOMORPHISM NP by describing a polynomial-time algorithm to verify the
27/03/2017
Math and Science in a Lapse of Reason: NP and Language Decidability
More
Next Blog
[email protected]
Dashboard
Sign Out
Math and Science in a Lapse
of Reason
Thursday, November 4, 2010
Followers
NP and Language Decidability
Today I am goi
CMPUT 204 Problem Set 5
(Partial solutions provided by Theo)
Topics covered in Part I are biconnected component
and minimum spanning tree; in Part II are Dijkstras
algorithm for single-source shortest paths, Strassens
matrix multiplication algorithm, P &
C OMPUTABILITY AND C OMPLEXITY
T UTORIAL 13
Tutorial 13
Exercise 1 (compulsory)
Prove that the class NP is closed under union, intersection, concatenation and Kleene star. Is the class NP
closed also under complement?
Solution:
It is an open problem wheth
27/03/2017
complexity theory - Proving that if coNP $\neq$ NP then P $\neq$ NP - Computer Science Stack Exchange
It is maybe easier to consider the contrapositive, that is P
So assume P
= NP NP = coNP P=NPNP=coNP.
= NP P=NP, then
1. for every L NPLNP, we
Co-NP Certifiers and Certificates
Co-NP Verifiers and Certificates
PRIME: Given integer s, is s prime?
COMPOSITE: Given integer s, is s composite?
Observation. s is composite if and
only if there exists an integer 1 < t < s
such that s is a multiple of t.
CSCI E-124Spring, 2017
Programming Assignment 3
Out: April 7, 2016
Due: April 23, 2017 (4:59 pm)
For this programming assignment, you will implement a number of heuristics for solving the N UMBER PAR problem, which is (of course) NP-complete. As input, th
CS 124
1
Midterm Review
3/4/17
Format
You will have 83 minutes to complete the exam. The exam will have true/false questions, multiple
choice, example/counterexample problems, run-this-algorithm problems, and problem set style
present-and-prove problems.
CS124Spring, 2017
Programming Assignment 2
Out: March 9, 2017
Due: March 24, 2017
Overview:
Strassens divide and conquer matrix multiplication algorithm for n by n matrices is asymptotically
faster than the conventional O(n3 ) algorithm. This means that f
CSCI E-124Spring, 2017
Homework 3
Out: Feb 14, 2013
Due: Feb 26, 2017
For all homework problems where you are asked to give an algorithm, you must prove the correctness of your algorithm
and establish the best upper bound that you can give for the running
CSCI E-124Spring, 2017
Programming Assignment 1
Out: February 14, 2017
Due: February 28, 2017 (5pm)
Overview:
The purpose of this assignment is to experience some of the problems involved with implementing an algorithm (in this case, a minimum spanning tr