<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>COMS 482 &#187; Class Notes</title>
	<atom:link href="http://cs482.elliottback.com/category/class-notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://cs482.elliottback.com</link>
	<description>unofficial class blog</description>
	<lastBuildDate>Sat, 11 Aug 2007 04:03:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lecture 35:  Knapsack Approximation Proofs</title>
		<link>http://cs482.elliottback.com/lecture-35-knapsack-approximation-proofs/</link>
		<comments>http://cs482.elliottback.com/lecture-35-knapsack-approximation-proofs/#comments</comments>
		<pubDate>Fri, 22 Apr 2005 16:11:29 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=45</guid>
		<description><![CDATA[In the previous lecture we showed an approximation to the Knapsack algorithm that is fast when v* = max vi is small.  So, convert a knapsack problem into one where v* is small by choosing b and converting vi -&#62; ceil(vi/b).  We want an answer within (1 + e) of the true value, [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous lecture we showed an <a href="http://cs482.elliottback.com/archives/2005/04/20/lecture-34-knapsack-approximations/">approximation</a> to the Knapsack algorithm that is fast when v<sup>*</sup> = max v<sub>i</sub> is small.  So, convert a knapsack problem into one where v<sup>*</sup> is small by choosing b and converting v<sub>i</sub> -&gt; ceil(v<sub>i</sub>/b).  We want an answer within (1 + e) of the true value, so b = (e/n) * v<sup>*</sup>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-35-knapsack-approximation-proofs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lecture 34:  Knapsack Approximations</title>
		<link>http://cs482.elliottback.com/lecture-34-knapsack-approximations/</link>
		<comments>http://cs482.elliottback.com/lecture-34-knapsack-approximations/#comments</comments>
		<pubDate>Wed, 20 Apr 2005 15:54:52 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=44</guid>
		<description><![CDATA[Some approximation bounds so far:

Makespan:  3/2, 4/3
Center selection:  2
Vertex cover: 2

The goal is to achieve a (1 + e) approximation.
Knapsack Problem:
We can carry at most W weight.  We have n items to choose from, each with weight wi and a value vi.  Our goal is to maximize value without exceeding weight [...]]]></description>
			<content:encoded><![CDATA[<p>Some approximation bounds so far:</p>
<ul>
<li>Makespan:  3/2, 4/3</li>
<li>Center selection:  2</li>
<li>Vertex cover: 2</li>
</ul>
<p>The goal is to achieve a (1 + e) approximation.</p>
<p><strong>Knapsack Problem:</strong></p>
<p>We can carry at most W weight.  We have n items to choose from, each with weight w<sub>i</sub> and a value v<sub>i</sub>.  Our goal is to maximize value without exceeding weight boundary W.  Using Dynamic Programming, we can define:</p>
<blockquote><p>Opt(i, V) = smallest weight possible using items {1, &#8230;, i} and choosing value &gt;= V.</p></blockquote>
<p>Given the Opt(*, *) function and W, we can search the opt-table to find the largest V for which opt(n, V) &lt;= W:</p>
<blockquote><p>V = sum(v<sub>i</sub> in S) &lt;= sum(v<sub>i</sub> for all i) &lt;= nv<sup>*</sup>, where v<sup>*</sup> = max v<sub>i</sub></p></blockquote>
<p>Therefore, the algorithm runs in time O(n<sup>2</sup>v<sup>*</sup>).</p>
<p><strong>Algorithm notes:</strong></p>
<p>If the nth item is not in opt solution, then Opt(n, V) = Opt(n-1, V).  If the nth item is in the optimal solution, then Opt(n, V) = w<sub>n</sub> + Opt(n-1, V-V<sub>n</sub>)&#8211;so, just take the minimum:</p>
<blockquote><p>Opt(n, V) = min({Opt(n-1, V), w<sub>n</sub> + Opt(n-1, V-V<sub>n</sub>})</p></blockquote>
<p>There are some table bounds to consider:</p>
<blockquote><p>Opt(1, V) = w<sub>1</sub> if v<sub>1</sub> &gt;= V, else infinity<br />
Opt(k, 0) = 0<br />
Opt(k, &lt; 0) = 0</p></blockquote>
<p>Finally, we can write the algorithm outline:</p>
<blockquote><p>Knapsack0Approx(e):<br />
&nbsp;&nbsp;&nbsp;&nbsp;b = (e/n) * max(v<sub>i</sub>)<br />
&nbsp;&nbsp;&nbsp;&nbsp;for all i v<sub>i</sub><sup>^</sup> = ceil(v<sub>i</sub>/b)<br />
&nbsp;&nbsp;&nbsp;&nbsp;solve problem with v<sub>i</sub><sup>^</sup> via DP outline above<br />
&nbsp;&nbsp;&nbsp;&nbsp;return result set S</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-34-knapsack-approximations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lecture 33:  Approximation of Vertex Cover</title>
		<link>http://cs482.elliottback.com/lecture-33-approximation-of-vertex-cover/</link>
		<comments>http://cs482.elliottback.com/lecture-33-approximation-of-vertex-cover/#comments</comments>
		<pubDate>Mon, 18 Apr 2005 07:32:13 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=42</guid>
		<description><![CDATA[Let xi be 0 if vi is not in the Vertex Cover, and 1 if vi is in the Vertex Cover.  (vi, vj) is an edge such that xi + xj &#62;= 1.  We want to make the sum of all xi as small as possible, and still cover the edges.
Linear Programming:
A set [...]]]></description>
			<content:encoded><![CDATA[<p>Let x<sub>i</sub> be 0 if v<sub>i</sub> is not in the Vertex Cover, and 1 if v<sub>i</sub> is in the Vertex Cover.  (v<sub>i</sub>, v<sub>j</sub>) is an edge such that x<sub>i</sub> + x<sub>j</sub> &gt;= 1.  We want to make the sum of all x<sub>i</sub> as small as possible, and still cover the edges.</p>
<p><strong>Linear Programming:</strong></p>
<p>A set of linear inequalities define a feasible region, for example:</p>
<blockquote><p>x + y &gt;=0<br />
x &#8211; y &gt;= 0<br />
x &lt;= 5<br />
y &lt;= 2</p></blockquote>
<p>Or, in matrix form:</p>
<blockquote><p>[[1,1][1,-1][1,0][0,1]] * [[x][y]] &gt;= [[0][0][-5][-2]]</p></blockquote>
<p>The goal is to remain the feasible region while optimizing something.  In general, given {Ax = b}, a set of linear inequalities, we want to minimize c*x, i.e. find the minimum {c*x | Ax &gt;= b}.  Geometrically, this is finding the extreme point of a polytope.  We can write this as a decision problem, too.  Given A, b, c, and a bound B, is there a solution x such that Ax &gt;= b and c&#8217;*x &lt;= B?</p>
<p>Claim: &#8220;LP is in NP&#8221;</p>
<p>Given a set of values, we can check the solution in polynomial time.  Rational numbers, however, require additional book keeping.  Beware!  Also, LP is in Co-NP and in P, using an interior point method.</p>
<p><strong>VC as a LP problem:</strong></p>
<p>x<sub>i</sub> &gt;= 0<br />
-x<sub>i</sub> &gt;= -1<br />
x<sub>i</sub> + x<sub>j</sub> 7gt;= 1 for all (v<sub>i</sub>, v<sub>j</sub>)<br />
minimize sum(x<sub>i</sub>)</p>
<p>Then, run LP but only allow integer solutions.  This is called &#8220;Integer Programming&#8221; (IP).  Claim:  &#8220;VC &lt;=<sub>p</sub> IP.&#8221;  Rewrite VC as an IP problem, then the solution to one implies the other.  Claim: &#8220;IP is in NP.&#8221;  Obvious.  Therefore, IP is NP-Complete.</p>
<p><strong>Approximation:</strong></p>
<p>Simply round the LP solution to get integers.  S = {i | i &gt;= 1/2}, our approximate vertex cover.  Then, |S| = sum(i in S) &lt;= sum(2*x<sub>i</sub> in S) = s * sum(x<sub>i</sub> in S) &lt;= 2 * sum(x<sub>i</sub> from i = 0 to n) &lt;= 2 * |S*|.  So, we are within a factor of two of the optimal solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-33-approximation-of-vertex-cover/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lecture 32: Center Selection</title>
		<link>http://cs482.elliottback.com/lecture-32/</link>
		<comments>http://cs482.elliottback.com/lecture-32/#comments</comments>
		<pubDate>Fri, 15 Apr 2005 17:07:33 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=41</guid>
		<description><![CDATA[Center Selection (CS):  Given n towns, place k malls, minimizing the worst driving distance.  The CS decision problem can be written: &#8220;Given n points, a radius r, and an integer k, can we place k disks of radius r so that all points are covered?&#8221;
dist(*,*) must satisfy:

dist(s, s) = 0 (reflexive)
dist(s, t) = [...]]]></description>
			<content:encoded><![CDATA[<p>Center Selection (CS):  Given n towns, place k malls, minimizing the worst driving distance.  The CS decision problem can be written: &#8220;Given n points, a radius r, and an integer k, can we place k disks of radius r so that all points are covered?&#8221;</p>
<p>dist(*,*) must satisfy:</p>
<ul>
<li>dist(s, s) = 0 (reflexive)</li>
<li>dist(s, t) = dist(t, s) (symmetry)</li>
<li>dist(s, u) &lt;= dist(s, t) + dist(t, u) (triangle inequality)</li>
</ul>
<p>CS<sub>decision</sub> &lt;=<sub>p</sub> CS<sub>optimization</sub>: Optimization is NP-hard!</p>
<p>Suppose that we know r and want to find a solution, i.e. choosing the centers.  If we already know one of the centers, uf we were to use radius 2r then any point within distance r can be used as the center, and all points will still be covered.  So, pick any point s in the disk; the circle with center s and radius 2r covers all the same points.</p>
<p>If there is a technique that produce an answer where radius &lt;= (2 &#8211; epsilon)r*, then p = NP.  In the plane, using Euclidean distance, if radius &lt;= (1.89 &#8230;)r*, then P = NP.</p>
<p>Greedy Algorithm:  Let S be the set of sites and C be the set of centers.  We are given r.</p>
<p>C = {}<br />
while S != {}<br />
&nbsp;&nbsp;&nbsp;&nbsp;choose s in S<br />
&nbsp;&nbsp;&nbsp;&nbsp;C = C + {s}<br />
&nbsp;&nbsp;&nbsp;&nbsp;delete all s&#8217; in S within 2r of s<br />
end<br />
if |C| &lt;= k return C<br />
else report &#8220;No solution for radius r possible&#8221;</p>
<p>Claim:  &#8220;If there is a solution using k radius-r disks, then the algorithm returns a solution using &lt;= k disks of radius 2r.</p>
<p>Each s chosen by the algorithm is in some disk (c*, r) for some c*.  Then the circle (s, 2r) covers all the same points covered by (c*, r) plus some more.  Thus, later choices of s are not covered by the circle (c*, r).  Each s chosen is covered by a different c* circle.  There are at most |c*| = k choices for s.  The algorithm produces &lt;= k disks of radius 2r covering all points.</p>
<p>Method:  Use a binary search to find the right radius.  First, box the set of points and find the maximum seperation between any 2 points.  This is R and r &lt;= R.  We can actually do better!  During the algorithm we need a point at distance &gt;= 2r from chosen site s.  Always choose the <em>fathest</em> point.  For later steps, choose s<sub>i</sub> farthest from existing centers.</p>
<p>New algorithm:  </p>
<p>Select any site s in S, let C = {s}<br />
while |c| &lt; k<br />
&nbsp;&nbsp;&nbsp;&nbsp;select s in S that maximizes that distance from s to any point in C<br />
&nbsp;&nbsp;&nbsp;&nbsp;C = C + {s}<br />
end<br />
return C</p>
<p>Claim:  &#8220;If there&#8217;s a solution (C*<sub>r</sub>, r) where |C*<sub>r</sub>|=k, then the algorithm returns a solution (C, 2r) where |c| = k.</p>
<p>Consider the previous algorithm.  We know there is an optimal value for r.  Let&#8217;s use that r.  Each s that is chosen in the new algorithm would be a valid s in the previous algorithm.  This holds until we eliminate all points in S, therefore we produce a cover (C, 2r).</p>
<p><span style="font-size:75%">Credit to Kevin Canini for the notes!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-32/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lecture 31: Greedy Reductions</title>
		<link>http://cs482.elliottback.com/lecture-31/</link>
		<comments>http://cs482.elliottback.com/lecture-31/#comments</comments>
		<pubDate>Thu, 14 Apr 2005 04:07:09 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=40</guid>
		<description><![CDATA[We can take a greedy approach, minimum makespan.  Given jobs for machines with times t1, t2, &#8230; , tn, the total time from start to finish of the slowest machine is as small as possible.  Example, three machines with jobs 2, 2, 2, 3, 4, 6:
M1: 2, 2, 2
M2: 3, 4
M3: 6
We can [...]]]></description>
			<content:encoded><![CDATA[<p>We can take a greedy approach, minimum makespan.  Given jobs for machines with times t<sub>1</sub>, t<sub>2</sub>, &#8230; , t<sub>n</sub>, the total time from start to finish of the slowest machine is as small as possible.  Example, three machines with jobs 2, 2, 2, 3, 4, 6:</p>
<blockquote><p>M<sub>1</sub>: 2, 2, 2<br />
M<sub>2</sub>: 3, 4<br />
M<sub>3</sub>: 6</p></blockquote>
<p>We can write this as a decision problem.  Given the number of machines and a list of job times, and a bound k, is there a way to assign jobs so that Makespan &lt;= k?  Makespan is NP-complete, by reduction from Subset Sum!  Given a target W and w<sub>1</sub>, w<sub>2</sub>, &#8230; , w<sub>n</sub>, split into sets W and S &#8211; W where S = sum(w<sub>i</sub>).   Take |W &#8211; (S &#8211; W)| = |2W &#8211; S| = W<sub>0</sub>, a new constant in  the list which forces the best solution where both subsets have the same sum = max(W, S &#8211; W).</p>
<p>Given a Subset Sum problem, create W<sub>0</sub> = |S &#8211; 2W| and let the w&#8217;s be the times of jobs.  Ask if Makespan works on 2 machines of size &lt;= (S + W<sub>0</sub>) / 2.</p>
<p>Claim:  &#8220;There is a solution to Subset Sum if and only if there is a solution to Makespan.&#8221;</p>
<p>Assume a Subset Sum solution.  Split the w&#8217;s into subsets that sum to W and S &#8211; W.  W<sub>0</sub> was chosen so we can make them equal, so there exists a Makespan = (S + W<sub>0</sub>) / 2, and some machine has a subset of jobs summing to W.</p>
<p>Greedy Strategy: Assign each job to least busy machine, incrementally.  How good is this?  Call the best Makespan possible T*.  The sum(t<sub>i</sub>) = total time to be spread over m machines.  Some machine must have more than sum(t<sub>i</sub>) / m, so T* &gt;= sum(t<sub>i</sub>) / m.  Consider M<sub>i</sub>, the machine with worst time; it&#8217;s load is T = T<sub>i</sub>.  In general, T<sub>j</sub> = load on M<sub>j</sub>.  Our makespan answer is T<sub>1</sub> by the greedy algorithm.</p>
<p>Let t<sub>j</sub> be the last time assigned to M<sub>i</sub>.  At that moment, M<sub>i</sub>&#8217;s load is T<sub>i</sub> &#8211; t<sub>j</sub>.  That must be the smallest load, because we chose it for the last job.  So T<sub>i</sub> &#8211; t<sub>j</sub> &lt;= T<sub>k</sub> for all k.</p>
<p>For each machine: M(T<sub>i</sub> &#8211; t<sub>j</sub>) &lt;= sum(T<sub>k</sub>) = sum(t<sub>j</sub>).  So T<sub>i</sub> &#8211; T<sub>j</sub> &lt; = sum(t<sub>j</sub>) / m &#038;;t= T*.  T<sub>i</sub> &#038;lt= T* + t<sub>j</sub> so T = T<sub>i</sub> &lt;= T* + t<sub>j</sub> and T* &gt;= worst t<sub>k</sub> &gt;= t<sub>j</sub>, so T &lt;= T* + T* -&gt; T &lt;= 2 T*.</p>
<p>The greedy algorithm is always within twice the optimal value.  If we presort and do the largest jobs first, we can show that T/T* &lt;= 3/2 and T/T* &lt;= 4/3.</p>
<p><span style="font-size:75%">Credit to Kevin Canini for the notes!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-31/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lecture 30: Review</title>
		<link>http://cs482.elliottback.com/lecture-30-review/</link>
		<comments>http://cs482.elliottback.com/lecture-30-review/#comments</comments>
		<pubDate>Tue, 12 Apr 2005 04:06:05 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=39</guid>
		<description><![CDATA[We reviewed for the prelim II today.  See previous post:  cs482.elliottback.com/archives/2005/04/10/prelim-ii-next-tuesday/
]]></description>
			<content:encoded><![CDATA[<p>We reviewed for the prelim II today.  See previous post:  <a href="http://cs482.elliottback.com/archives/2005/04/10/prelim-ii-next-tuesday/" title="http://cs482.elliottback.com/archives/2005/04/10/prelim-ii-next-tuesday/" target="_blank">cs482.elliottback.com/archives/2005/04/10/prelim-ii-next-tuesday/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-30-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lecture 29:  Handling NP-Complete Problems</title>
		<link>http://cs482.elliottback.com/lecture-29-handling-np-complete-problems/</link>
		<comments>http://cs482.elliottback.com/lecture-29-handling-np-complete-problems/#comments</comments>
		<pubDate>Thu, 07 Apr 2005 00:15:13 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=38</guid>
		<description><![CDATA[There are two general strategies for dealing with those recalcitrant NP-complete problems.  You can either take advantage of special characteristics of the problem, or you can come up with an approximate solution.  In this lecture, we will be looking at the former.
Imagine what happens when you run Independent Set on a Tree:

The nodes [...]]]></description>
			<content:encoded><![CDATA[<p>There are two general strategies for dealing with those recalcitrant NP-complete problems.  You can either take advantage of special characteristics of the problem, or you can come up with an approximate solution.  In this lecture, we will be looking at the former.</p>
<p>Imagine what happens when you run Independent Set on a Tree:</p>
<p><img src="http://cs482.elliottback.com/wp-content/l29d1-independent-set-tree.png" width="328" height="266" alt="Independent Set as Tree" /></p>
<p>The nodes of the indepent set are labelled in red.  How do we get an independent set for a tree?  Simply, choosing the leaves first is optimal:</p>
<p>Let T = (V, E) be a tree and v be a leaf vertex.  I claim that there is a maximum size independent set that contains v.  Consider a max size independent set S.  If v is in S, we are done.  Assume v is not in S.  Let u be a parent of v.  If u is not in S, we can put v in S instead to get a larger independent set.  If u is in S, we can take out u and put v into S to get S&#8217;, an independent set of same size = max size.</p>
<p>Here is an algorithm:</p>
<p>Place all leaves into S<br />
while S is not empty {<br />
&nbsp;&nbsp;&nbsp;&nbsp;Color the leaves<br />
&nbsp;&nbsp;&nbsp;&nbsp;Delete leaves and parents<br />
}</p>
<p>You can implement this in linear time using DFS&#8211;and even if your graph is not a tree, it still may have some tree-like pieces.</p>
<p><strong>Sample NP-Complete Reductions:</strong></p>
<p>Given n processes and m resources:</p>
<p>a)  Each process needs several resources at once.  Is there a way for k processes to be active at the same time?</p>
<blockquote><p>Some ideas include Set Packing, Independent Set.  To do it with Set Packing, you would ask if there are k subsets of processes that don&#8217;t intersect over resources.</p></blockquote>
<p>b)  Special case of (a) where k = 2.</p>
<p>c)  Special case of (a) where there are 2 types of resources and processes require at most one of each type.</p>
<p>d)  Each resource is requested by at most 2 processes.</p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-29-handling-np-complete-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lecture 28:  PSPACE</title>
		<link>http://cs482.elliottback.com/lecture-28-pspace/</link>
		<comments>http://cs482.elliottback.com/lecture-28-pspace/#comments</comments>
		<pubDate>Tue, 05 Apr 2005 00:13:19 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=37</guid>
		<description><![CDATA[PSPACE = {x &#124; x has a polynomial space algorithm}
Given T = c1 ^ c2 ^ &#8230; ^ ck where each clauses ci is an OR-clause with 3 terms (an instance of 3-SAT) , does there exist and x1 for all x2 does there exist an x3 for all x4 &#8230; for all xn-1 such [...]]]></description>
			<content:encoded><![CDATA[<p>PSPACE = {x | x has a polynomial space algorithm}</p>
<p>Given T = c1 ^ c2 ^ &#8230; ^ ck where each clauses c<sub>i</sub> is an OR-clause with 3 terms (an instance of 3-SAT) , does there exist and x1 for all x2 does there exist an x3 for all x4 &#8230; for all xn-1 such that T is true?  This is called quantified 3-SAT (QSAT), an is a kind of alternation thatsshows up in many game AI questions.  I.e., is there a move for me such that for all of my opponents&#8217; next move there is another good move for me such that &#8230; etc.</p>
<p>One idea for QSAT&#8211;try all truth assignments.  Define:  p<sup>w</sup> = polynomial time algorithm given an &#8220;oracle&#8221; for w.  What if you need a solution to an NP-complete problem?  Sometimes there are special characteristics of a problem that allows a solution.  Sometimes we can define a provably good approximation solution!</p>
<p>Look at vertex cover.  Given G, k, is there a vertex cover of size &lt;= k?  So, there are n choose k possible vertex covers.  We could try them all, but&#8230; that&#8217;s a lot of options.  To check a vertex cover, try each edge e, see if at least one endpoint is in the cover, and repeat.  This takes O(n<sup>2</sup>) time.</p>
<p>Claim:  &#8220;If G has n nodes, with max-degree d, and if there is a vertex cover of size k, then G has at most k*d edges.&#8221;</p>
<p>k*d is better than O(n<sup>2</sup>).  Let s be the vertex cover with |s| = k.  There are at most d edges from each vertex in S, there are at most k*d places where S touches some edge either once or twice.  |E| &lt;= # touches &lt;= k*d, so trying all the possibilities is no longer O(n choose k * k * (n-1)) but rather O(n<sup>k+1</sup> * k).</p>
<p>Observe that any graph with more than k*(n-1) edges cannot have a vertex cover of size k, and if there is a vertex cover of size k and we completely remove a vertex from the cover, then the remaining graph has a vertex cover of size k-1.</p>
<p>Find(G, k):<br />
&nbsp;&nbsp;&nbsp;&nbsp;if G has no edges return false<br />
&nbsp;&nbsp;&nbsp;&nbsp;if G has more than k*(n-1) edges return false<br />
&nbsp;&nbsp;&nbsp;&nbsp;choose e = (u, v)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s1 = find(G &#8211; {u}, k-1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s2 = find(G &#8211; {v}, k-1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if s1 and s2 fail, then return false<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(s1)  return s1 + {u}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(s2)  return s2 + {v}</p>
<p>This algorithm is O(k*n*2<sup>k+1</sup>).  The proof is left as an exercise to the reader.</p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-28-pspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lecture 27:  P, NP, Co-NP, NP-Complete, PSPACE</title>
		<link>http://cs482.elliottback.com/lecture-27-p-np-co-np-np-complete-pspace/</link>
		<comments>http://cs482.elliottback.com/lecture-27-p-np-co-np-np-complete-pspace/#comments</comments>
		<pubDate>Fri, 01 Apr 2005 23:38:21 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=35</guid>
		<description><![CDATA[Recall that we write &#8220;x is in P if there exists a polynomial time algorithm a(*) such that s is in x if and only a(s) returns yes.&#8221;  Define x&#8217; = { s &#124; s not in x}.  Is x&#8217; in P?  Yes, because we can define a&#8217;(*) as follows:
if a(s) returns [...]]]></description>
			<content:encoded><![CDATA[<p>Recall that we write &#8220;x is in P if there exists a polynomial time algorithm a(*) such that s is in x if and only a(s) returns yes.&#8221;  Define x&#8217; = { s | s not in x}.  Is x&#8217; in P?  Yes, because we can define a&#8217;(*) as follows:</p>
<blockquote><p>if a(s) returns &#8220;yes&#8221; then return &#8220;no&#8221; otherwise return &#8220;yes&#8221;</p></blockquote>
<p>Let y be in NP.  What about y&#8217;?  Let y&#8217; = {s | s not in y}.  To say &#8220;y is in NP&#8221; means that there exists a polynomial time certifier b(*,*): s is in y if and only if there exists t such that b(s, t) returns &#8220;yes,&#8221; in polynomial bounded size.  So, let&#8217;s look at y&#8217;:</p>
<blockquote><p>s in y&#8217;<br />
&lt;=&gt; s not in y<br />
&lt;=&gt; ! there exists t such that b(s,t) returns &#8220;yes&#8221;<br />
&lt;=&gt; for all t, b(s, t) returns &#8220;no&#8221;</p></blockquote>
<p>Co-NP = {y&#8217; | y is in NP}.  Does NP = Co-NP?  We don&#8217;t know.  If we assume P=NP, though, it follows that P=Co-NP as well.  Generally the consensus is that NP does not equal Co-NP.  Here is a diagram that might help explain P, NP, Co-NP, and PSPACE:</p>
<p><img src="http://cs482.elliottback.com/wp-content/l27d1-p-np-conp-pspace.png" width="174" height="171" alt="P, NP, Co-NP, and PSPACE" /></p>
<p>P-SPACE is defined as {x | x has an algorithm using at most polynomial space}.  P is a subset of PSPACE, because you cannot use more than polynomial space in only polynomial time.  To say x is in PSPACE implies that x&#8217; is in PSPACE using the same inversion algorithm as above.  You can also create the following chain:</p>
<blockquote><p>x in Co-NP =&gt; x&#8217; in NP =&gt; x&#8217; in SPACE =&gt; x in PSPACE</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-27-p-np-co-np-np-complete-pspace/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lecture 26: The Travelling Salesman Problem</title>
		<link>http://cs482.elliottback.com/lecture-26-the-travelling-salesman-problem/</link>
		<comments>http://cs482.elliottback.com/lecture-26-the-travelling-salesman-problem/#comments</comments>
		<pubDate>Wed, 30 Mar 2005 22:44:32 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Class Notes]]></category>

		<guid isPermaLink="false">/?p=34</guid>
		<description><![CDATA[The Travelling Salesman Problem (TSP):
Given distances between n cities and a bound D, is there a tour (visit all cities and return home) of cost at most D?  Note that using TSP to prove NP-completeness of other problems is quite hard.
Claim:  &#8220;TSP is NP-complete&#8221;
Proof:  TSP is in the set NP.  Given [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The Travelling Salesman Problem (TSP)</strong>:</p>
<p>Given distances between n cities and a bound D, is there a tour (visit all cities and return home) of cost at most D?  Note that using TSP to prove NP-completeness of other problems is quite hard.</p>
<p>Claim:  &#8220;TSP is NP-complete&#8221;</p>
<p>Proof:  TSP is in the set NP.  Given a valid tour, we can check that it is valid and has a cost &#038;lt= D in polynomial time.  Then, we want to show that Hamiltonian Cycle reduces to TSP in polynomial time.  Given an HC problem as a graph G, we can show how to build the travelling salesman problem.  Using the same vertices, place an edge between each pair with cost 1 if the edge exists in G, otherwise place the edge with cost 2.</p>
<p>Claim:  &#8220;G has a Hamiltonian Cycle if and only if G&#8217; has a TSP tour of cost &#038;lt= n (vertices)&#8221;</p>
<p>Proof (=&gt;):  Assume G has a HC.  Then the cycle in G&#8217; is a tour and its cost is &lt;= n.</p>
<p>Proof (&lt;=):  Assume G&#8217; has a TSP tour of cost &lt;= n.  Every node is visited, and each edge has cost 1.  The corresponding cycle is a valid HC.</p>
<p><strong>3D Matching:</strong></p>
<p>Given disjoint sets X, Y, and Z each of size n and given a set of triples T is a subset of  (X, Y, Z) is there a subset of T of size n that covers all X + Y + Z?  We can show that 3-SAT reduces to 3D Matching in polynomial time, so 3D matching is NP-complete.</p>
<p><strong>Graph Coloring:</strong></p>
<p>A graph g is said to have a k-coloring if there is a way to assign colors to vertices such that all adjacent verticex do not share the same color.  Given a graph g and a bound k, is G k-colorable?  Graph coloring is NP-complete, but on planar graphs 2-coloring has a simple DFS algorithm, and &gt;=4-coloring simply returns &#8220;yes.&#8221;</p>
<p><strong>Subset Sum:</strong></p>
<p>Given w<sub>1</sub>, &#8230; , w<sub>n</sub> in {Naturals} and a target w<sub>i</sub> is there a subset of w<sub>1</sub>, &#8230; , w<sub>n</sub> whose sum is exactly w<sub>i</sub>?</p>
<p><strong>NP-Complete &#8220;Types&#8221;:</strong></p>
<p>All the NP Complete problems we have covered so far can be grouped by similarity into the following categories:</p>
<ul>
<li><em>Packing problems: </em> Set Packing, Independent Set</li>
<li><em>Covering problems: </em> Vertex &#038; Set Cover</li>
<li><em>Partitioning problems: </em> 3D Matching, Graph coloring</li>
<li><em>Sequencing problems: </em> Hamiltonian Cycle, Hamiltonian Path, Travelling Salesman Problem</li>
<li><em>Numerical problems: </em> Subset sum</li>
<li><em>Constraint problems: </em> SAT, 3-SAT, and Circuit-SAT</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/lecture-26-the-travelling-salesman-problem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
