<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="th-TH">
	<id>https://srakrn.me/mediawiki/index.php?action=history&amp;feed=atom&amp;title=SKE_Algo_II_%28Winter_2019%29%2FHomework_1%2FSolution</id>
	<title>SKE Algo II (Winter 2019)/Homework 1/Solution - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://srakrn.me/mediawiki/index.php?action=history&amp;feed=atom&amp;title=SKE_Algo_II_%28Winter_2019%29%2FHomework_1%2FSolution"/>
	<link rel="alternate" type="text/html" href="https://srakrn.me/mediawiki/index.php?title=SKE_Algo_II_(Winter_2019)/Homework_1/Solution&amp;action=history"/>
	<updated>2026-04-05T16:03:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>https://srakrn.me/mediawiki/index.php?title=SKE_Algo_II_(Winter_2019)/Homework_1/Solution&amp;diff=118&amp;oldid=prev</id>
		<title>Srakrn: /* Problem 5 */</title>
		<link rel="alternate" type="text/html" href="https://srakrn.me/mediawiki/index.php?title=SKE_Algo_II_(Winter_2019)/Homework_1/Solution&amp;diff=118&amp;oldid=prev"/>
		<updated>2020-03-05T08:56:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Problem 5&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;th-TH&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 08:56, 5 March 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l55&quot; &gt;Line 55:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 55:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Example: Given the list of events A to F as follows:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Example: Given the list of events A to F as follows:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;img src=&amp;quot;https&lt;/del&gt;:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;//edufarm.ku.ac.th/draftfile.php/52661/user/draft/512860086/algoii&lt;/del&gt;-hw1-failedschedule-c.png&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; alt=&amp;quot;&amp;quot; role=&amp;quot;presentation&amp;quot; class=&amp;quot;img-responsive atto_image_button_text-bottom&amp;quot; width=&amp;quot;1920&amp;quot; height=&amp;quot;502&amp;quot;&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[File&lt;/ins&gt;:&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Algoii&lt;/ins&gt;-hw1-failedschedule-c.png&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|thumb|center]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The algorithm will choose event A and C first as each of them has only 1 overlapping event, then it will choose event D and E as each of them has 2 overlaping events. No more events can be chosen, so the algorithm returns [A, C, D, E] as the scheduling problem's solution.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The algorithm will choose event A and C first as each of them has only 1 overlapping event, then it will choose event D and E as each of them has 2 overlaping events. No more events can be chosen, so the algorithm returns [A, C, D, E] as the scheduling problem's solution.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l61&quot; &gt;Line 61:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 61:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Solution ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Solution ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;img src=&amp;quot;https&lt;/del&gt;:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;//edufarm.ku.ac.th/draftfile.php/52661/user/draft/43300127/algoii&lt;/del&gt;-hw1-failedschedule-c-soln.png&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;quot; alt=&amp;quot;&amp;quot; role=&amp;quot;presentation&amp;quot; class=&amp;quot;img-responsive atto_image_button_text-bottom&amp;quot; width=&amp;quot;1920&amp;quot; height=&amp;quot;518&amp;quot;&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This is one of the failing case&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[File:Algoii&lt;/ins&gt;-hw1-failedschedule-c-soln.png&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;|thumb|center]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Srakrn</name></author>
		
	</entry>
	<entry>
		<id>https://srakrn.me/mediawiki/index.php?title=SKE_Algo_II_(Winter_2019)/Homework_1/Solution&amp;diff=115&amp;oldid=prev</id>
		<title>Srakrn at 08:54, 5 March 2020</title>
		<link rel="alternate" type="text/html" href="https://srakrn.me/mediawiki/index.php?title=SKE_Algo_II_(Winter_2019)/Homework_1/Solution&amp;diff=115&amp;oldid=prev"/>
		<updated>2020-03-05T08:54:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;th-TH&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 08:54, 5 March 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Consider the Gale-Shapley's algorithm mentioned in the classroom.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Consider the Gale-Shapley's algorithm mentioned in the classroom.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We define non-stable pairs &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_i, g_j)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;such that there exists &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;preceeding &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;'s preference list, and there also exists &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;preceeding &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;'s preference list.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We define non-stable pairs &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_i, g_j)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;such that there exists &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;preceeding &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;'s preference list, and there also exists &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;preceeding &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;'s preference list.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Proof that the Gale-Shapley's algorithm would not create any non-stable pairs.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Proof that the Gale-Shapley's algorithm would not create any non-stable pairs.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Solution ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Solution ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;From the definition of non-stable pair, it could be shown that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;precedes &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;'s preference list, and that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;precedes &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;'s preference list.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;From the definition of non-stable pair, it could be shown that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;precedes &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;'s preference list, and that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;precedes &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;'s preference list.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;i &amp;lt; j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;, the Gale-Shapley algorithm would not cause the break-up between the pair &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_i, g_i)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;, as the break-up will occur only when &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;precedes &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;'s preference order.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;i &amp;lt; j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;, the Gale-Shapley algorithm would not cause the break-up between the pair &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_i, g_i)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;, as the break-up will occur only when &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;precedes &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;'s preference order.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;i &amp;gt; j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;, the Gale-Shapley algorithm would cause the break-up between the pair &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i, g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;since the preference of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;on &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;is higher than on &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;i &amp;gt; j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;, the Gale-Shapley algorithm would cause the break-up between the pair &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i, g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;since the preference of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;on &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;is higher than on &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Problem 3 =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Problem 3 =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Consider the stable marriage problem mentioned in the classroom.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Consider the stable marriage problem mentioned in the classroom.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Given that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;'s first preferred match is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;, and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;'s first preferred match is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;, proof that the there exists &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_i, g_j)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;pair in any stable matchings.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Given that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;'s first preferred match is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;, and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;'s first preferred match is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;, proof that the there exists &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_i, g_j)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;pair in any stable matchings.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Note: Do not proof with Gale-Shapley's algorithm. Use stable matching definition.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Note: Do not proof with Gale-Shapley's algorithm. Use stable matching definition.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Solution==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Solution==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We need to proof that if &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;M&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;is stable then there exists &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_i, g_j)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;pair.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We need to proof that if &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;M&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;is stable then there exists &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_i, g_j)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;pair.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We'll consider the proof by contradiction. Suppose our stable pairs &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;M&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;contains the matching between &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_i, g_x)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_x, g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;). As &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_i&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;prefers &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;more than &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_x&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;prefers &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;b_j&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;more than &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;g_x&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;, we could show that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_i, g_j)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;is a rouge pair in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;M&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\)&lt;/del&gt;, therefore &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;M&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;is not stable.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;We'll consider the proof by contradiction. Suppose our stable pairs &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;M&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;contains the matching between &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_i, g_x)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_x, g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;). As &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_i&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;prefers &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;more than &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_x&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;prefers &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;b_j&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;more than &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;g_x&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;, we could show that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_i, g_j)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;is a rouge pair in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;M&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt;&lt;/ins&gt;, therefore &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;M&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;is not stable.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As our conclusion does not agree with our hypothesis, thus we proof by contradiction that if &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;M&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;is stable, then there exists &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\(&lt;/del&gt;(b_i, g_j)&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\) &lt;/del&gt;pair.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As our conclusion does not agree with our hypothesis, thus we proof by contradiction that if &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;M&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;is stable, then there exists &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;&lt;/ins&gt;(b_i, g_j)&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/math&amp;gt; &lt;/ins&gt;pair.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Problem 4A =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Problem 4A =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Srakrn</name></author>
		
	</entry>
	<entry>
		<id>https://srakrn.me/mediawiki/index.php?title=SKE_Algo_II_(Winter_2019)/Homework_1/Solution&amp;diff=114&amp;oldid=prev</id>
		<title>Srakrn: Created page with &quot;= Problem 2 =  Consider the Gale-Shapley's algorithm mentioned in the classroom.  We define non-stable pairs \((b_i, g_j)\) such that there exists \(g_i\) preceeding \(g_j\) i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://srakrn.me/mediawiki/index.php?title=SKE_Algo_II_(Winter_2019)/Homework_1/Solution&amp;diff=114&amp;oldid=prev"/>
		<updated>2020-03-05T08:53:27Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Problem 2 =  Consider the Gale-Shapley&amp;#039;s algorithm mentioned in the classroom.  We define non-stable pairs \((b_i, g_j)\) such that there exists \(g_i\) preceeding \(g_j\) i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Problem 2 =&lt;br /&gt;
&lt;br /&gt;
Consider the Gale-Shapley's algorithm mentioned in the classroom.&lt;br /&gt;
&lt;br /&gt;
We define non-stable pairs \((b_i, g_j)\) such that there exists \(g_i\) preceeding \(g_j\) in \(b_j\)'s preference list, and there also exists \(b_j\) preceeding \(b_i\) in \(g_j\)'s preference list.&lt;br /&gt;
&lt;br /&gt;
Proof that the Gale-Shapley's algorithm would not create any non-stable pairs.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
From the definition of non-stable pair, it could be shown that \(g_i\) precedes \(g_j\) in \(b_i\)'s preference list, and that \(b_j\) precedes \(b_i\) in \(g_j\)'s preference list.&lt;br /&gt;
&lt;br /&gt;
For \(i &amp;lt; j\), the Gale-Shapley algorithm would not cause the break-up between the pair \((b_i, g_i)\), as the break-up will occur only when \(g_j\) precedes \(g_i\) in \(b_i\)'s preference order.&lt;br /&gt;
&lt;br /&gt;
For \(i &amp;gt; j\), the Gale-Shapley algorithm would cause the break-up between the pair \(b_i, g_j\) since the preference of \(g_j\) on \(b_j\) is higher than on \(b_i\).&lt;br /&gt;
&lt;br /&gt;
= Problem 3 =&lt;br /&gt;
Consider the stable marriage problem mentioned in the classroom.&lt;br /&gt;
&lt;br /&gt;
Given that \(b_i\)'s first preferred match is \(g_i\), and \(g_j\)'s first preferred match is \(b_j\), proof that the there exists \((b_i, g_j)\) pair in any stable matchings.&lt;br /&gt;
&lt;br /&gt;
Note: Do not proof with Gale-Shapley's algorithm. Use stable matching definition.&lt;br /&gt;
&lt;br /&gt;
==Solution==&lt;br /&gt;
We need to proof that if \(M\) is stable then there exists \((b_i, g_j)\) pair.&lt;br /&gt;
&lt;br /&gt;
We'll consider the proof by contradiction. Suppose our stable pairs \(M\) contains the matching between \((b_i, g_x)\) and \((b_x, g_j\)). As \(b_i\) prefers \(g_j\) more than \(g_x\) and \(g_j\) prefers \(b_j\) more than \(g_x\), we could show that \((b_i, g_j)\) is a rouge pair in \(M\), therefore \(M\) is not stable.&lt;br /&gt;
&lt;br /&gt;
As our conclusion does not agree with our hypothesis, thus we proof by contradiction that if \(M\) is stable, then there exists \((b_i, g_j)\) pair.&lt;br /&gt;
&lt;br /&gt;
= Problem 4A =&lt;br /&gt;
Given this weighted scheduling algorithm, give an counterexample on why it fails:&lt;br /&gt;
&lt;br /&gt;
Given the schedule (which is the list of events to attend), greedily attend the event that begins first.&lt;br /&gt;
&lt;br /&gt;
Example: If there are four event at (1) 9:00 - 10:00, (2) 10:00 - 12:00, (3) 11:00 - 12:00, and (4) 13:00 - 14:00, this algorithm will attend event number 1, 2, and 4.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
Let there be three event at (a) 8:00 - 16:00, (b) 9:00 - 10:00, and (c) 11:00 - 12:00, this algorithm will fail since it will attend only event (a).&lt;br /&gt;
&lt;br /&gt;
= Problem 4B =&lt;br /&gt;
Given this weighted scheduling algorithm, give an counterexample on why it fails:&lt;br /&gt;
&lt;br /&gt;
Given the schedule (which is the list of events to attend), greedily attend the event that is the shortest in time.&lt;br /&gt;
&lt;br /&gt;
Example: If there are four event at (1) 9:00 - 10:00, (2) 10:00 - 12:00, (3) 11:00 - 12:00, and (4) 13:00 - 14:00, this algorithm will attend event number 1, 3, and 4.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
Let there be three event at (a) 8:00 - 10:00, (b) 9:00 - 10:00, and (c) 10:00 - 12:00, this algorithm will fail since it will attend only event (b).&lt;br /&gt;
&lt;br /&gt;
= Problem 5 =&lt;br /&gt;
Given this weighted scheduling algorithm, give an counterexample on why it fails:&lt;br /&gt;
&lt;br /&gt;
Given the schedule (which is the list of events to attend), greedily attend the event that is least overlapped.&lt;br /&gt;
&lt;br /&gt;
Example: Given the list of events A to F as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;img src=&amp;quot;https://edufarm.ku.ac.th/draftfile.php/52661/user/draft/512860086/algoii-hw1-failedschedule-c.png&amp;quot; alt=&amp;quot;&amp;quot; role=&amp;quot;presentation&amp;quot; class=&amp;quot;img-responsive atto_image_button_text-bottom&amp;quot; width=&amp;quot;1920&amp;quot; height=&amp;quot;502&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The algorithm will choose event A and C first as each of them has only 1 overlapping event, then it will choose event D and E as each of them has 2 overlaping events. No more events can be chosen, so the algorithm returns [A, C, D, E] as the scheduling problem's solution.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;img src=&amp;quot;https://edufarm.ku.ac.th/draftfile.php/52661/user/draft/43300127/algoii-hw1-failedschedule-c-soln.png&amp;quot; alt=&amp;quot;&amp;quot; role=&amp;quot;presentation&amp;quot; class=&amp;quot;img-responsive atto_image_button_text-bottom&amp;quot; width=&amp;quot;1920&amp;quot; height=&amp;quot;518&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Srakrn</name></author>
		
	</entry>
</feed>