<?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; Exams</title>
	<atom:link href="http://cs482.elliottback.com/category/exams/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>Final Review: Chapters 1 to 4</title>
		<link>http://cs482.elliottback.com/final-review-chapters-1-to-4/</link>
		<comments>http://cs482.elliottback.com/final-review-chapters-1-to-4/#comments</comments>
		<pubDate>Sat, 14 May 2005 21:42:09 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Exams]]></category>

		<guid isPermaLink="false">/?p=46</guid>
		<description><![CDATA[Stable Matching, Marriage:
Given some sets M = {m1, &#8230; , mn} and W = {w1, &#8230; , wn}  representing men and women, we want to find a perfect stable matching.

A matching is a set of ordered pairs in MxW such that every m, w appear at most once.
In a perfect matching, each m, w [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Stable Matching, Marriage:</strong></p>
<p>Given some sets M = {m<sub>1</sub>, &#8230; , m<sub>n</sub>} and W = {w<sub>1</sub>, &#8230; , w<sub>n</sub>}  representing men and women, we want to find a <em>perfect stable matching</em>.</p>
<ul>
<li>A <em>matching</em> is a set of ordered pairs in MxW such that every m, w appear at most once.</li>
<li>In a <em>perfect matching</em>, each m, w appear exactly once.</li>
<li>An <em>instability</em> occurs when there are two pairs (m, w) and (m&#8217;, w&#8217;) such that m prefers w&#8217; to w, and w&#8217; prefers m to m&#8217;.</li>
</ul>
<p><strong>Gale-Shapely Algorithm:</strong></p>
<p>Initialize all m in M and w in W to free<br />
while there exists free man m who still has a woman w to propose to {<br />
w = m&#8217;s highest ranked such woman<br />
if w is free<br />
engage (m, w)<br />
else some pair (m&#8217;, w) already exists<br />
if w prefers m to m&#8217;<br />
(m, w) become married<br />
m&#8217; becomes free<br />
else<br />
(m&#8217;, w) remain married<br />
}</p>
<p>Termination is obvious.  Show there are no instabilities by simple contradition.  See Lecture 1 for more on <a title="Gale Shapely Stable Matching" href="http://cs482.elliottback.com/archives/2005/01/24/lecture-1-stable-matching/">Stable Matching / Marriage</a>.</p>
<p><strong>Breadth First Search:</strong></p>
<p>BFS can be used to identify connected components as well as for testing bipartiteness of graphs.  If there are no edges joining nodes in the same BFS layer, then the graph must contain an odd length cycle and be non-bipartite.  For more about BFS, see lecture 7 on <a title="BFS Algorithms" href="http://cs482.elliottback.com/archives/2005/02/07/lecture-7-various-bfs-derivatives/">Breadth-First Search</a>.</p>
<p><strong>Greedy Algorithms:</strong></p>
<ul>
<li><strong>Interval Scheduling:</strong>  Schedule non-overlapping requests to a certain interval, maximizing the size of the compatible set.<br />
<blockquote><p>Simply choose requests with the smallest finishing time, and delete all overlapping requests until done.  Proof proceeds by &#8220;stays ahead&#8221; argument.</p></blockquote>
<p>See lecture 3 for a <a title="Greedy Interval Scheduling" href="http://cs482.elliottback.com/archives/2005/01/28/lecture-3-greedy-algorithms/">proof of optimality</a>.</li>
<li><strong>Interval Partitioning:</strong>  Schedule all intervals across a minimal number of resources so that none of the intervals scheduled to a particular resource overlap.  The number of resources needed is at least the maximum depth of the set of intervals.<br />
<blockquote><p>Sort the intervals by start times.  Assign a label to the first interval.  Then, choose the next interval I<sub>i</sub>.  For every interval I<sub>bad</sub> before I<sub>i</sub> that overlaps it, remove I<sub>bad</sub>&#8217;s label from consideration.  Then, assign a non-excluded label to I<sub>i</sub>, if there is one.</p></blockquote>
</li>
<li><strong>Scheduling to Minimize Lateness:</strong>  Sort by the earliest deadlines and schedule in this order.<br />
<blockquote><p>There&#8217;s an optimal schedule with no idle time&#8211;our algorithm also has no idle time.  If there is an inversion in the optimal solution, there d<sub>i</sub> &gt; d<sub>j</sub> and j is scheduled after i.  If we swap i and j, we keep the same lateness, so the greddy algorithm is optimal by an <em>exchange argument</em>.</p></blockquote>
</li>
<li><strong>Dijkstra&#8217;s Algorithm:</strong>  Find the shortest path from a given node to all other nodes (Single Source Shortest Path, SSSP):<br />
<blockquote><p>Choose a start node s in V<br />
PQ.put(s, 0)<br />
While PQ != {}<br />
(u, d) = PQ.getMin()<br />
if u is <em>done</em> then continue<br />
mark u as <em>done</em> (or report (u, d))<br />
for v adjacent to u do<br />
PQ.put(v, d + dist(u,v));<br />
end for<br />
end while</p></blockquote>
</li>
</ul>
<p><strong>Greedy MST Problems:</strong></p>
<ul>
<li><strong>Kruskal&#8217;s Algorithm:</strong><br />
<blockquote><p>Sort <em>edges</em> by cost<br />
<em>T</em> = {}<br />
for <em>e</em> in <em>edges</em> do<br />
if <em>e</em> does not create a cycle then<br />
add <em>e</em> to <em>T</em><br />
endif<br />
endfor</p></blockquote>
</li>
<li><strong>Prim&#8217;s Algorithm:</strong><br />
<blockquote><p>Choose a start vertex <em>s</em><br />
<em>T</em> = {<em>s</em>}<br />
While there is a vertex not in <em>T</em> do<br />
choose least cost edge from <em>T</em> to some vertex not in <em>T</em><br />
add this edge to <em>T</em><br />
endwhile</p></blockquote>
</li>
<li><strong>Reverse Delete Algorithm:</strong><br />
<blockquote><p>Sort <em>edges</em> by cost, decreasing<br />
<em>T</em> = E, the edge set<br />
for <em>e</em> in <em>T</em> do<br />
if removing <em>e</em> does not disconnect the graph then<br />
T = T &#8211; {<em>e</em>}<br />
endif<br />
endfor</p></blockquote>
</li>
</ul>
<p>All of these MST algorithms can be implemented in O(m log n) time.  Lecture 4 contains a <a href="http://cs482.elliottback.com/archives/2005/01/31/lecture-4-minimum-spanning-trees/">proof that Kruskal&#8217;s algorithm produces an MST</a>, lecture 5 proves the same for <a href="http://cs482.elliottback.com/archives/2005/02/02/lecture-5-how-to-prove-greedy-algorithms/">Prim&#8217;s algorithm</a>, and lecture 6 carefully proves the <a href="http://cs482.elliottback.com/archives/2005/02/04/lecture-6-kruskals-runtime/">time complexity of Kruskal&#8217;s algorithm</a>.</p>
<p>Two interesting MST facts:</p>
<ul>
<li>The most expensive edge of a cycle on G is not in any MST</li>
<li>The min cost edge between V-S and S, where S is a strict subset of V, is in the MST</li>
</ul>
<p>Also, make sure you know how union find operates, replacing parent pointers with a pointer to the root on find() operations, and joining trees smaller  to larger on union() operations to keep the trees balanced.</p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/final-review-chapters-1-to-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prelim II Next Tuesday</title>
		<link>http://cs482.elliottback.com/prelim-ii-next-tuesday/</link>
		<comments>http://cs482.elliottback.com/prelim-ii-next-tuesday/#comments</comments>
		<pubDate>Sun, 10 Apr 2005 17:08:24 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Exams]]></category>

		<guid isPermaLink="false">/?p=36</guid>
		<description><![CDATA[Prelim II is next Tuesday.  The announcement isn&#8217;t on the course website yet, but here are review questions from 2000 spring, for the eager:

You are given a graph G = (V, E) with weights we on its edges {e in E}. The weights can be negative or positive. The Zero-­weight-cycle problem is to decide [...]]]></description>
			<content:encoded><![CDATA[<p>Prelim II is next Tuesday.  The announcement isn&#8217;t on the course website yet, but here are review questions from <a href="http://www.cs.cornell.edu/courses/cs482/2000sp/">2000 spring</a>, for the eager:</p>
<ol>
<li>You are given a graph G = (V, E) with weights w<sub>e</sub> on its edges {e in E}. The weights can be negative or positive. The Zero-­weight-cycle problem is to decide if there is a simple cycle in G so that the sum of the edge weights on this cycle is exactly 0.
<p>Prove that this problem is NP­complete.</li>
<li style="margin-top:16px;">Since the 3­Dimensional Matching problem is NP­complete, it is natural to expect that the  corresponding 4­Dimensional Matching problem is at least as hard. Let us define 4­Dimensional  Matching as follows. Given sets W , X , Y , and Z, each of size n, and a collection C of ordered 4­tuples of the form (w<sub>i</sub> , x<sub>j</sub>, y<sub>k</sub>, z<sub>l</sub>), do there exist n 4-­tuples from C so that no two have an element in common?
<p>Prove that 4­Dimensional Matching is NP­complete.</li>
<li style="margin-top:16px;">Some of your friends have recently graduated and started a small company called WebExodus, which they are currently running out of their parents&#8217; garages in Santa Clara. They&#8217;re in the process of porting all their software from an old system to a new, revved­up system; and they&#8217;re facing the following problem.
<p>They have a collection of n software applications, {1, 2, . . . , n}, running on their old system; and they&#8217;d like to port some of these to the new system. If they move application i to the new system, they expect a net (monetary) benefit of b<sub>i</sub> &gt;= 0. The different software applications interact with one another; if applications i and j have extensive interaction, then the company will incur an expense if they move one of i or j to the new system but not both &#8212; let&#8217;s denote this expense by x<sub>i,j</sub> &gt;= 0. </p>
<p>So if the situation were really this simple, your friends would just port all n applications, achieving a total benefit of sum(b<sub>i</sub> . Unfortunately, there&#8217;s a problem . . .  Due to small but fundamental incompatibilities between the two systems, there&#8217;s no way to port application 1 to the new system; it will have to remain on the old system. Nevertheless, it might still pay to port some of the other applications, accruing the associated benefit and incurring the expense of the interaction between applications on different systems. </p>
<p>So this is the question they pose to you: which of the remaining applications, if any, should be moved? Give a polynomial­ time algorithm to find a set S # {2, 3, . . . , n} for which the sum of the benefits minus the expenses of moving the applications in S to the new system is maximized. </li>
</ol>
<p><strong>Update:</strong></p>
<p>New review problems have been posted here:  <a href="http://www.cs.cornell.edu/courses/cs482/2005sp/review2.htm" title="http://www.cs.cornell.edu/courses/cs482/2005sp/review2.htm" target="_blank">www.cs.cornell.edu/courses/cs482/2005sp/review2.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/prelim-ii-next-tuesday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prelim 1 Coming!</title>
		<link>http://cs482.elliottback.com/prelim-1-coming/</link>
		<comments>http://cs482.elliottback.com/prelim-1-coming/#comments</comments>
		<pubDate>Sun, 20 Feb 2005 19:41:51 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Exams]]></category>

		<guid isPermaLink="false">/?p=18</guid>
		<description><![CDATA[We&#8217;ve got a prelim on thursday&#8211;here are some study tips:  www.cs.cornell.edu/courses/cs482/2005sp/review1.htm
]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got a prelim on thursday&#8211;here are some study tips:  <a href="http://www.cs.cornell.edu/courses/cs482/2005sp/review1.htm" title="http://www.cs.cornell.edu/courses/cs482/2005sp/review1.htm" target="_blank">www.cs.cornell.edu/courses/cs482/2005sp/review1.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cs482.elliottback.com/prelim-1-coming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
