<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wcipeg.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Change_problem</id>
		<title>Change problem - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wcipeg.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Change_problem"/>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;action=history"/>
		<updated>2026-05-09T15:14:01Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.2</generator>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2189&amp;oldid=prev</id>
		<title>162.158.62.147: Undo revision 2174 by 172.68.244.110 (talk)</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2189&amp;oldid=prev"/>
				<updated>2020-02-05T15:51:31Z</updated>
		
		<summary type="html">&lt;p&gt;Undo revision 2174 by &lt;a href=&quot;/wiki/Special:Contributions/172.68.244.110&quot; title=&quot;Special:Contributions/172.68.244.110&quot;&gt;172.68.244.110&lt;/a&gt; (&lt;a href=&quot;/wiki/index.php?title=User_talk:172.68.244.110&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User talk:172.68.244.110 (page does not exist)&quot;&gt;talk&lt;/a&gt;)&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 15:51, 5 February 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L4&quot; &gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; 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:black; 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;The &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;men&lt;/del&gt;'&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;s prostate &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;central &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the a part of a male&lt;/del&gt;'&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;s the reproductive system. It secretes fluids that aid &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the transportation and activation of sperm&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;The prostate gland is situated just while watching rectum&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;below the bladder and around the urethra. When there is prostate problem&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;it will always be really miserable and inconvenient to the patient as his urinary system is directly affected&lt;/del&gt;. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;==Discussion of complexity==&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;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;corresponding decision problem, which simply asks us to determine whether or not making change is &lt;/ins&gt;'&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'possible'' with the given denominations (which it might not be, if we are missing the denomination 1) &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;known &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;be [[NP-complete]].&amp;lt;ref&amp;gt;G. S. Lueker. (1975). &lt;/ins&gt;'&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'Two NP-complete problems &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;nonnegative integer programming&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'' Technical Report 178&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Computer Science Laboratory&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Princeton University&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(&lt;/ins&gt;The &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;authors were not able to obtain a copy &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;this paper&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;but in the literature it &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;invariably cited to back up &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;claim that change is NP&lt;/ins&gt;-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;complete&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;)&amp;lt;/ref&amp;gt; It follows that &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;optimization and counting problems &lt;/ins&gt;are &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;both [[NP&lt;/ins&gt;-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;hard]] (''e.g.''&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/ins&gt;the result of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;0 for the counting problem answers the decision problem &lt;/ins&gt;in the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;negative&lt;/ins&gt;, and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;any nonzero value answers it in the affirmative&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;color:black; 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;The &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;common prostate health conditions are prostate infection, enlarged prostate and prostate type &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;cancer. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&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:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;However, as we shall see, &lt;/ins&gt;a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;simple &amp;lt;math&amp;gt;O(nT)&amp;lt;/math&amp;gt; solution exists for both versions &lt;/ins&gt;of the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;problem&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Why then are these problems not &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;P? The answer &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;that &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''size'' of &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;input required &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;represent &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;actually &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''length'' &lt;/ins&gt;of the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;which &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;\Theta(\log T)&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is expressed in binary (or decimal, or whatever)&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Thus, &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;time &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;space required by the algorithm &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;actually &amp;lt;math&amp;gt;O(n &lt;/ins&gt;2&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;^{\lg T})&amp;lt;/math&amp;gt;, &lt;/ins&gt;that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is, exponential in the size of the input&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(This simplified analysis does not take into account the sizes &lt;/ins&gt;of the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;denominations&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;but captures the essence &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the argument&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;) This algorithm &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;then said &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;be ''pseudo-polynomial''&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;No true polynomial-time algorithm is known (&lt;/ins&gt;and, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;indeed, none will be found unless it turns out that P = NP)&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;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;Prostate infection, often known as prostatitis&lt;/del&gt;, is the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;most common prostate&lt;/del&gt;-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;related overuse injury in men younger than 55 years old&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Infections in &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;prostate gland &lt;/del&gt;are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;classified into four types &lt;/del&gt;- &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;acute bacterial prostatitis&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;chronic bacterial prostatitis, chronic abacterial prostatitis and prosttodynia. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;Acute bacterial prostatitis may be &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;least common of all kinds of prostate infection. It is a &lt;/del&gt;result of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;bacteria based &lt;/del&gt;in the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;large intestines or urinary tract. Patients can experience fever&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;chills, body aches, back pains &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;urination problems. This condition is treated by utilizing antibiotics or non-steroid anti-inflammatory drugs (NSAIDs&lt;/del&gt;) &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;to alleviate the swelling&lt;/del&gt;. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;Chronic bacterial prostatitis is &lt;/del&gt;a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;condition &lt;/del&gt;of the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;particular defect inside the gland and also the persistence presence of bacteria inside urinary tract&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;It can be brought on by trauma to the urinary tract or by infections via other parts &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the body. A patient may experience testicular pain, lower back pains and urination problems. Although it &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;uncommon, it could be treated by removal in &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;prostate defect as well as &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;use antibiotics and NSAIDs &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;deal with &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;inflammation. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;Non-bacterial prostatitis &lt;/del&gt;is the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;reason approximately 90% &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;most prostatitis cases; however, researchers have not yet to create &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;cause of these conditions. Some researchers feel that chronic non-bacterial prostatitis occur as a result of unknown infectious agents while other think that intensive exercise and heavy lifting may cause these infections. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;Maintaining a Healthy Prostate &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;To prevent prostate diseases&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;an appropriate diet &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;important&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;These are some with &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;things you can do &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;also hardwearing . prostate healthy. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;1. Drink sufficient water. Proper hydration &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;necessary for general health and it'll also keep your urinary track clean. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;2&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;. Some studies declare &lt;/del&gt;that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;a few ejaculations weekly will help to prevent prostate cancer&lt;/del&gt;. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;3. Eat beef sparingly. It has been shown that consuming a lot more than four meals &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;beef per week will raise &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;chance of prostate diseases and cancer. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;4. Maintain a proper diet with cereals&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;vegetable and fruits to make sure sufficient intake &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;nutrients required for prostate health&lt;/del&gt;. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;The most significant measure to look at to make certain a healthy prostate &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;usually &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;select regular prostate health screening&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;If you are forty yrs . old &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;above&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;you should select prostate examination at least per year&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>162.158.62.147</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2174&amp;oldid=prev</id>
		<title>172.68.244.110: How To Prevent Prostate Problems And Diseases?</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2174&amp;oldid=prev"/>
				<updated>2018-06-26T06:06:31Z</updated>
		
		<summary type="html">&lt;p&gt;How To Prevent Prostate Problems And Diseases?&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 06:06, 26 June 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L4&quot; &gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; 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:black; 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;==Discussion of complexity==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;men&lt;/ins&gt;'&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;s prostate &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;central &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the a part of a male&lt;/ins&gt;'&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;s the reproductive system. It secretes fluids that aid &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the transportation and activation of sperm&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The prostate gland is situated just while watching rectum&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;below the bladder and around the urethra. When there is prostate problem&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;it will always be really miserable and inconvenient to the patient as his urinary system is directly affected&lt;/ins&gt;. &amp;#160;&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:black; 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;The &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;corresponding decision problem, which simply asks us to determine whether or not making change is &lt;/del&gt;'&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'possible'' with the given denominations (which it might not be, if we are missing the denomination 1) &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;known &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be [[NP-complete]].&amp;lt;ref&amp;gt;G. S. Lueker. (1975). &lt;/del&gt;'&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'Two NP-complete problems &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;nonnegative integer programming&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'' Technical Report 178&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Computer Science Laboratory&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Princeton University&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(&lt;/del&gt;The &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;authors were not able to obtain a copy &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;this paper&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;but in the literature it &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;invariably cited to back up &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;claim that change is NP&lt;/del&gt;-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;complete&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;)&amp;lt;/ref&amp;gt; It follows that &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;optimization and counting problems &lt;/del&gt;are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;both [[NP&lt;/del&gt;-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;hard]] (''e.g.''&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;because &lt;/del&gt;the result of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;0 for the counting problem answers the decision problem &lt;/del&gt;in the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;negative&lt;/del&gt;, and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;any nonzero value answers it in the affirmative&lt;/del&gt;).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &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;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;common prostate health conditions are prostate infection, enlarged prostate and prostate type &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;cancer. &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;color:black; 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;However, as we shall see, &lt;/del&gt;a &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;simple &amp;lt;math&amp;gt;O(nT)&amp;lt;/math&amp;gt; solution exists for both versions &lt;/del&gt;of the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;problem&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Why then are these problems not &lt;/del&gt;in &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;P? The answer &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;that &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;''size'' of &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;input required &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;represent &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;actually &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;''length'' &lt;/del&gt;of the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;which &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;math&amp;gt;\Theta(\log T)&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is expressed in binary (or decimal, or whatever)&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Thus, &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;time &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;space required by the algorithm &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;actually &amp;lt;math&amp;gt;O(n &lt;/del&gt;2&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;^{\lg T})&amp;lt;/math&amp;gt;, &lt;/del&gt;that &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;is, exponential in the size of the input&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(This simplified analysis does not take into account the sizes &lt;/del&gt;of the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;denominations&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;but captures the essence &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the argument&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;) This algorithm &lt;/del&gt;is &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;then said &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;be ''pseudo-polynomial''&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;No true polynomial-time algorithm is known (&lt;/del&gt;and, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;indeed, none will be found unless it turns out that P = NP)&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;Prostate infection, often known as prostatitis&lt;/ins&gt;, is the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;most common prostate&lt;/ins&gt;-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;related overuse injury in men younger than 55 years old&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Infections in &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;prostate gland &lt;/ins&gt;are &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;classified into four types &lt;/ins&gt;- &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;acute bacterial prostatitis&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;chronic bacterial prostatitis, chronic abacterial prostatitis and prosttodynia. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;Acute bacterial prostatitis may be &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;least common of all kinds of prostate infection. It is a &lt;/ins&gt;result of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;bacteria based &lt;/ins&gt;in the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;large intestines or urinary tract. Patients can experience fever&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;chills, body aches, back pains &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;urination problems. This condition is treated by utilizing antibiotics or non-steroid anti-inflammatory drugs (NSAIDs&lt;/ins&gt;) &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;to alleviate the swelling&lt;/ins&gt;. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;Chronic bacterial prostatitis is &lt;/ins&gt;a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;condition &lt;/ins&gt;of the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;particular defect inside the gland and also the persistence presence of bacteria inside urinary tract&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;It can be brought on by trauma to the urinary tract or by infections via other parts &lt;/ins&gt;in &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the body. A patient may experience testicular pain, lower back pains and urination problems. Although it &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;uncommon, it could be treated by removal in &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;prostate defect as well as &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;use antibiotics and NSAIDs &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;deal with &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;inflammation. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;Non-bacterial prostatitis &lt;/ins&gt;is the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;reason approximately 90% &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;most prostatitis cases; however, researchers have not yet to create &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;cause of these conditions. Some researchers feel that chronic non-bacterial prostatitis occur as a result of unknown infectious agents while other think that intensive exercise and heavy lifting may cause these infections. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;Maintaining a Healthy Prostate &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;To prevent prostate diseases&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;an appropriate diet &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;important&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;These are some with &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;things you can do &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;also hardwearing . prostate healthy. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;1. Drink sufficient water. Proper hydration &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;necessary for general health and it'll also keep your urinary track clean. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;2&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. Some studies declare &lt;/ins&gt;that &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;a few ejaculations weekly will help to prevent prostate cancer&lt;/ins&gt;. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;3. Eat beef sparingly. It has been shown that consuming a lot more than four meals &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;beef per week will raise &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;chance of prostate diseases and cancer. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;4. Maintain a proper diet with cereals&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;vegetable and fruits to make sure sufficient intake &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;nutrients required for prostate health&lt;/ins&gt;. &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The most significant measure to look at to make certain a healthy prostate &lt;/ins&gt;is &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;usually &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;select regular prostate health screening&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;If you are forty yrs . old &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;above&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;you should select prostate examination at least per year&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>172.68.244.110</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2153&amp;oldid=prev</id>
		<title>162.158.126.60: Undo revision 2152 by 172.68.238.234 (talk)</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2153&amp;oldid=prev"/>
				<updated>2017-09-09T11:03:21Z</updated>
		
		<summary type="html">&lt;p&gt;Undo revision 2152 by &lt;a href=&quot;/wiki/Special:Contributions/172.68.238.234&quot; title=&quot;Special:Contributions/172.68.238.234&quot;&gt;172.68.238.234&lt;/a&gt; (&lt;a href=&quot;/wiki/index.php?title=User_talk:172.68.238.234&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User talk:172.68.238.234 (page does not exist)&quot;&gt;talk&lt;/a&gt;)&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 11:03, 9 September 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L4&quot; &gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; 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:black; 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; By dealing together&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;you both can address &lt;/del&gt;problems of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;self&lt;/del&gt;-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;esteem &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;mutual trust&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt; Once you discover &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;top natural cures&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;you &lt;/del&gt;are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;able &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;again have full charge &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;your sexual pleasures&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;==Discussion of complexity==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The corresponding decision problem&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;which simply asks us to determine whether or not making change is ''possible'' with the given denominations (which it might not be, if we are missing the denomination 1) is known to be [[NP-complete]].&amp;lt;ref&amp;gt;G. S. Lueker. (1975). ''Two NP-complete &lt;/ins&gt;problems &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;in nonnegative integer programming.'' Technical Report 178, Computer Science Laboratory, Princeton University. (The authors were not able to obtain a copy &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;this paper, but in the literature it is invariably cited to back up the claim that change is NP&lt;/ins&gt;-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;complete.)&amp;lt;/ref&amp;gt; It follows that the optimization &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;counting problems are both [[NP-hard]] (''e&lt;/ins&gt;.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;g.'', because the result of 0 for the counting problem answers the decision problem in &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;negative&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and any nonzero value answers it in the affirmative).&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;However, as we shall see, a simple &amp;lt;math&amp;gt;O(nT)&amp;lt;/math&amp;gt; solution exists for both versions of the problem. Why then &lt;/ins&gt;are &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;these problems not in P? The answer is that the ''size'' of the input required &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;represent the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is actually the ''length'' &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which is &amp;lt;math&amp;gt;\Theta(\log T)&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is expressed in binary (or decimal, or whatever). Thus, the time and space required by the algorithm is actually &amp;lt;math&amp;gt;O(n 2^{\lg T})&amp;lt;/math&amp;gt;, that is, exponential in the size of the input. (This simplified analysis does not take into account the sizes of the denominations, but captures the essence of the argument.) This algorithm is then said to be ''pseudo-polynomial''. No true polynomial-time algorithm is known (and, indeed, none will be found unless it turns out that P = NP)&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>162.158.126.60</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2152&amp;oldid=prev</id>
		<title>172.68.238.234: How Kegel Exercises Make Your Erectile Dysfunction Worse</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=2152&amp;oldid=prev"/>
				<updated>2017-09-05T17:55:41Z</updated>
		
		<summary type="html">&lt;p&gt;How Kegel Exercises Make Your Erectile Dysfunction Worse&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 17:55, 5 September 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L4&quot; &gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; 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:black; 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;==Discussion of complexity==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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; By dealing together&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;you both can address &lt;/ins&gt;problems of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;self&lt;/ins&gt;-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;esteem &lt;/ins&gt;and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;mutual trust&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; Once you discover &lt;/ins&gt;the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;top natural cures&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;you &lt;/ins&gt;are &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;able &lt;/ins&gt;to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;again have full charge &lt;/ins&gt;of &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;your sexual pleasures&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;color:black; 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;The corresponding decision problem&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;which simply asks us to determine whether or not making change is ''possible'' with the given denominations (which it might not be, if we are missing the denomination 1) is known to be [[NP-complete]].&amp;lt;ref&amp;gt;G. S. Lueker. (1975). ''Two NP-complete &lt;/del&gt;problems &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;in nonnegative integer programming.'' Technical Report 178, Computer Science Laboratory, Princeton University. (The authors were not able to obtain a copy &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;this paper, but in the literature it is invariably cited to back up the claim that change is NP&lt;/del&gt;-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;complete.)&amp;lt;/ref&amp;gt; It follows that the optimization &lt;/del&gt;and &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;counting problems are both [[NP-hard]] (''e&lt;/del&gt;.&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;g.'', because the result of 0 for the counting problem answers the decision problem in &lt;/del&gt;the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;negative&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;and any nonzero value answers it in the affirmative).&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; 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;However, as we shall see, a simple &amp;lt;math&amp;gt;O(nT)&amp;lt;/math&amp;gt; solution exists for both versions of the problem. Why then &lt;/del&gt;are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;these problems not in P? The answer is that the ''size'' of the input required &lt;/del&gt;to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;represent the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is actually the ''length'' &lt;/del&gt;of &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which is &amp;lt;math&amp;gt;\Theta(\log T)&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is expressed in binary (or decimal, or whatever). Thus, the time and space required by the algorithm is actually &amp;lt;math&amp;gt;O(n 2^{\lg T})&amp;lt;/math&amp;gt;, that is, exponential in the size of the input. (This simplified analysis does not take into account the sizes of the denominations, but captures the essence of the argument.) This algorithm is then said to be ''pseudo-polynomial''. No true polynomial-time algorithm is known (and, indeed, none will be found unless it turns out that P = NP)&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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 class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Greedy algorithm==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>172.68.238.234</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=1829&amp;oldid=prev</id>
		<title>174.116.183.57: /* Greedy algorithm */</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=1829&amp;oldid=prev"/>
				<updated>2014-10-12T17:27:24Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Greedy algorithm&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 17:27, 12 October 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L12&quot; &gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Many real-world currency systems admit a [[greedy solution]] to the optimization version of the change problem. This algorithm is as follows: repeatedly choose the largest denomination that is less than or equal to the target amount, and ''use it'', that is, subtract it from the target amount, and then repeat this procedure on the reduced value, until the target amount decreases to zero. For example, with Canadian currency, we can greedily make change for $0.63 as follows: the largest denomination that fits into $0.63 is $0.25, so we subtract that (and thus resolve to use a $0.25 coin); we are left with $0.38, and take out another $0.25, so we subtract that again to obtain $0.13 (so that we have used two $0.25 coins so far); now the largest denomination that fits is $0.10, so we subtract that out, leaving us with $0.03; and then we subtract three $0.01 coins, leaving us with $0.00, at which point the algorithm terminates; so we have used six coins (two $0.25 coins, one $0.10 coin, and three $0.01 coins).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Many real-world currency systems admit a [[greedy solution]] to the optimization version of the change problem. This algorithm is as follows: repeatedly choose the largest denomination that is less than or equal to the target amount, and ''use it'', that is, subtract it from the target amount, and then repeat this procedure on the reduced value, until the target amount decreases to zero. For example, with Canadian currency, we can greedily make change for $0.63 as follows: the largest denomination that fits into $0.63 is $0.25, so we subtract that (and thus resolve to use a $0.25 coin); we are left with $0.38, and take out another $0.25, so we subtract that again to obtain $0.13 (so that we have used two $0.25 coins so far); now the largest denomination that fits is $0.10, so we subtract that out, leaving us with $0.03; and then we subtract three $0.01 coins, leaving us with $0.00, at which point the algorithm terminates; so we have used six coins (two $0.25 coins, one $0.10 coin, and three $0.01 coins).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; 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:black; 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;It turns out that the greedy algorithm ''always'' gives the correct result for both Canadian and United States currencies (the proof is left as an exercise for the reader). There are various other real-world currency systems for which this is also true. However, there are simple examples of sets of denominations for which the greedy algorithm does ''not'' give a correct solution. For example, with the set of denominations &amp;lt;math&amp;gt;{1, 3, 4}&amp;lt;/math&amp;gt;, the greedy algorithm will change 6 as 4+1+1, using three coins, whereas the correct minimal solution is obviously 3+3. There are also cases in which the greedy algorithm will fail to make change at all (consider what happens if we try to change &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;7 &lt;/del&gt;using the denominations &amp;lt;math&amp;gt;{3, 4}&amp;lt;/math&amp;gt;). This usually does not occur in real-world systems because they tend to have denominations that are quite a bit more &amp;quot;spaced out&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;It turns out that the greedy algorithm ''always'' gives the correct result for both Canadian and United States currencies (the proof is left as an exercise for the reader). There are various other real-world currency systems for which this is also true. However, there are simple examples of sets of denominations for which the greedy algorithm does ''not'' give a correct solution. For example, with the set of denominations &amp;lt;math&amp;gt;{1, 3, 4}&amp;lt;/math&amp;gt;, the greedy algorithm will change 6 as 4+1+1, using three coins, whereas the correct minimal solution is obviously 3+3. There are also cases in which the greedy algorithm will fail to make change at all (consider what happens if we try to change &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;6 &lt;/ins&gt;using the denominations &amp;lt;math&amp;gt;{3, 4}&amp;lt;/math&amp;gt;). This usually does not occur in real-world systems because they tend to have denominations that are quite a bit more &amp;quot;spaced out&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Obviously, there is no greedy solution to the counting problem.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Obviously, there is no greedy solution to the counting problem.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>174.116.183.57</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=1637&amp;oldid=prev</id>
		<title>Brian at 18:00, 10 March 2012</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=1637&amp;oldid=prev"/>
				<updated>2012-03-10T18:00:52Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 18:00, 10 March 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L5&quot; &gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Discussion of complexity==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Discussion of complexity==&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:black; 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;The corresponding decision problem, which simply asks us to determine whether or not making change is ''possible'' with the given denominations (which it might not be, if we are missing the denomination 1) is known to be [[NP-complete]].&amp;lt;ref&amp;gt;G. S. Lueker. (1975). ''Two NP-complete problems in nonnegative integer programming.'' Technical Report 178, Computer Science Laboratory, Princeton University&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;''&lt;/del&gt;&amp;lt;/ref&amp;gt; It follows that the optimization and counting problems are both [[NP-hard]] (''e.g.'', because the result of 0 for the counting problem answers the decision problem in the negative, and any nonzero value answers it in the affirmative).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The corresponding decision problem, which simply asks us to determine whether or not making change is ''possible'' with the given denominations (which it might not be, if we are missing the denomination 1) is known to be [[NP-complete]].&amp;lt;ref&amp;gt;G. S. Lueker. (1975). ''Two NP-complete problems in nonnegative integer programming.'' Technical Report 178, Computer Science Laboratory, Princeton University&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. (The authors were not able to obtain a copy of this paper, but in the literature it is invariably cited to back up the claim that change is NP-complete.)&lt;/ins&gt;&amp;lt;/ref&amp;gt; It follows that the optimization and counting problems are both [[NP-hard]] (''e.g.'', because the result of 0 for the counting problem answers the decision problem in the negative, and any nonzero value answers it in the affirmative).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, as we shall see, a simple &amp;lt;math&amp;gt;O(nT)&amp;lt;/math&amp;gt; solution exists for both versions of the problem. Why then are these problems not in P? The answer is that the ''size'' of the input required to represent the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is actually the ''length'' of the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which is &amp;lt;math&amp;gt;\Theta(\log T)&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is expressed in binary (or decimal, or whatever). Thus, the time and space required by the algorithm is actually &amp;lt;math&amp;gt;O(n 2^{\lg T})&amp;lt;/math&amp;gt;, that is, exponential in the size of the input. (This simplified analysis does not take into account the sizes of the denominations, but captures the essence of the argument.) This algorithm is then said to be ''pseudo-polynomial''. No true polynomial-time algorithm is known (and, indeed, none will be found unless it turns out that P = NP).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, as we shall see, a simple &amp;lt;math&amp;gt;O(nT)&amp;lt;/math&amp;gt; solution exists for both versions of the problem. Why then are these problems not in P? The answer is that the ''size'' of the input required to represent the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is actually the ''length'' of the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which is &amp;lt;math&amp;gt;\Theta(\log T)&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is expressed in binary (or decimal, or whatever). Thus, the time and space required by the algorithm is actually &amp;lt;math&amp;gt;O(n 2^{\lg T})&amp;lt;/math&amp;gt;, that is, exponential in the size of the input. (This simplified analysis does not take into account the sizes of the denominations, but captures the essence of the argument.) This algorithm is then said to be ''pseudo-polynomial''. No true polynomial-time algorithm is known (and, indeed, none will be found unless it turns out that P = NP).&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;L19&quot; &gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The optimization problem exhibits optimal substructure, in the sense that if we remove any coin of value &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; from the optimal means of changing &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, then the set of coins remaining is an optimal means of changing &amp;lt;math&amp;gt;T - D_i&amp;lt;/math&amp;gt;. This is because if this were ''not'' so; that is, there existed a means of changing &amp;lt;math&amp;gt;T - D_i&amp;lt;/math&amp;gt; that used fewer coins than what we obtained by removing the coin &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; from our supposed optimal change for &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, then we could just add the coin &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; back in and get change for the original amount &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; in fewer coins, a contradiction. Therefore, if we let &amp;lt;math&amp;gt;f(x)&amp;lt;/math&amp;gt; denote the minimal number of coins required to change amount &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, then we can write &amp;lt;math&amp;gt;f(x) = 1 + \min_i f(x - D_i)&amp;lt;/math&amp;gt;; we consider all possible minimal solutions to &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; minus one coin, and take the best one and add that coin back in to get minimal change for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. The base case is &amp;lt;math&amp;gt;f(0) = 0&amp;lt;/math&amp;gt;; obviously, 0 coins are required to make change for 0. See [[Dynamic_programming#Optimization_example:_Change_problem|the DP article]] for details and an implementation.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The optimization problem exhibits optimal substructure, in the sense that if we remove any coin of value &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; from the optimal means of changing &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, then the set of coins remaining is an optimal means of changing &amp;lt;math&amp;gt;T - D_i&amp;lt;/math&amp;gt;. This is because if this were ''not'' so; that is, there existed a means of changing &amp;lt;math&amp;gt;T - D_i&amp;lt;/math&amp;gt; that used fewer coins than what we obtained by removing the coin &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; from our supposed optimal change for &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, then we could just add the coin &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; back in and get change for the original amount &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; in fewer coins, a contradiction. Therefore, if we let &amp;lt;math&amp;gt;f(x)&amp;lt;/math&amp;gt; denote the minimal number of coins required to change amount &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, then we can write &amp;lt;math&amp;gt;f(x) = 1 + \min_i f(x - D_i)&amp;lt;/math&amp;gt;; we consider all possible minimal solutions to &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; minus one coin, and take the best one and add that coin back in to get minimal change for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. The base case is &amp;lt;math&amp;gt;f(0) = 0&amp;lt;/math&amp;gt;; obviously, 0 coins are required to make change for 0. See [[Dynamic_programming#Optimization_example:_Change_problem|the DP article]] for details and an implementation.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; 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:black; 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;TODO: &lt;/del&gt;counting problem&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The &lt;/ins&gt;counting problem &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;is more subtle. We cannot approach it in quite the same way as we approach the optimization problem, because the counting problem does not exhibit disjoint substructure when it is &amp;quot;sliced&amp;quot; this way. For example, if the denominations are 2 and 3, and the target amount is 5, then we might try to conclude that the number of ways of changing 5 is the number of ways of changing 2 plus the number of ways of changing 3, because we can either add a coin of value 2 to any way of changing 3 or add a coin of value 3 to any way of changing 2. Alas, this gives the incorrect answer that there are 2 ways of changing 5, whereas in actual fact we double-counted the solution 2+3 and there is, in fact, only one way to change 5.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;The solution in this case is to compute the function &amp;lt;math&amp;gt;f(x, n)&amp;lt;/math&amp;gt;, the number of ways to make change for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; ''using only the first &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; denominations'' (and not necessarily all of them). The base case is &amp;lt;math&amp;gt;f(0, 0) = 1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;f(x, 0) = 0&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;x &amp;gt; 0&amp;lt;/math&amp;gt;; we don't need any coins to make change for the amount 0, and there is exactly one way to make change for 0, that is, the zero tuple. On the other hand, we obviously cannot change any nonzero amount if we are not allowed to use any denominations at all.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;Now here comes the disjoint and exhaustive substructure. To make change for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; using only the first &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; denominations, we have two disjoint and exhaustive options: either we can use at least one coin of denomination &amp;lt;math&amp;gt;D_n&amp;lt;/math&amp;gt;, or we can use none at all. The number of ways of making change for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; using no coins of denomination &amp;lt;math&amp;gt;D_n&amp;lt;/math&amp;gt; is &amp;lt;math&amp;gt;f(x, n-1)&amp;lt;/math&amp;gt;. As for the ways of using at least one coin of denomination &amp;lt;math&amp;gt;D_n&amp;lt;/math&amp;gt;, they can be put in one-to-one correspondence with ways of making change for &amp;lt;math&amp;gt;x-D_n&amp;lt;/math&amp;gt; with only the first &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; coins (simply by addition or removal of one coin of denomination &amp;lt;math&amp;gt;D_n&amp;lt;/math&amp;gt;). We conclude that &amp;lt;math&amp;gt;f(x, n) = f(x, n-1) + f(x - D_n, n)&amp;lt;/math&amp;gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;We can implement this algorithm in &amp;lt;math&amp;gt;O(T)&amp;lt;/math&amp;gt; space by running it one column at a time; that is, the value &amp;lt;math&amp;gt;f(x, n)&amp;lt;/math&amp;gt; does not depend on any &amp;lt;math&amp;gt;f(x', n')&amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt;n' &amp;lt; n - 1&amp;lt;/math&amp;gt;, so we only need to keep the last two columns at any given point. In fact, we do not even need two columns; the only value from the previous column that the computation of &amp;lt;math&amp;gt;f(x, n)&amp;lt;/math&amp;gt; requires is &amp;lt;math&amp;gt;f(x, n-1)&amp;lt;/math&amp;gt;, so we can overwrite in-place with the new value (the old value will never be needed for the rest of this column). Here is pseudocode:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;input T, n, array D&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;dp[0] &amp;amp;larr; 1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;for i &amp;amp;isin; [1..T]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160; &amp;#160; dp[i] &amp;amp;larr; 0&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;for j &amp;amp;isin; [1..n]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160; &amp;#160; for i &amp;amp;isin; [D[j]..T]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;#160; &amp;#160; &amp;#160; &amp;#160; dp[i] &amp;amp;larr; dp[i] + dp[i-D[j]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;print dp[T]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; 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;Should we actually wish to print out all ways of making change, the corresponding recursive descent algorithm would be a sound choice.&amp;lt;sup&amp;gt;[elaborate?]&amp;lt;/sup&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Notes and References==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Notes and References==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;references/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;references/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	<entry>
		<id>http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=1635&amp;oldid=prev</id>
		<title>Brian: Created page with &quot;The ''change-making problem'', often simply known as '''change''', occurs in two distinct but related flavours. Given a set of natural numbers &lt;math&gt;D_1, D_2, ..., D_n&lt;/math&gt; (th...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wcipeg.com/wiki/index.php?title=Change_problem&amp;diff=1635&amp;oldid=prev"/>
				<updated>2012-03-10T00:13:56Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;The &amp;#039;&amp;#039;change-making problem&amp;#039;&amp;#039;, often simply known as &amp;#039;&amp;#039;&amp;#039;change&amp;#039;&amp;#039;&amp;#039;, occurs in two distinct but related flavours. Given a set of natural numbers &amp;lt;math&amp;gt;D_1, D_2, ..., D_n&amp;lt;/math&amp;gt; (th...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The ''change-making problem'', often simply known as '''change''', occurs in two distinct but related flavours. Given a set of natural numbers &amp;lt;math&amp;gt;D_1, D_2, ..., D_n&amp;lt;/math&amp;gt; (the ''denominations'') and a natural number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; (the target amount for which to make change):&lt;br /&gt;
* ''Optimization problem'': Make change for the target amount using as few total coins as possible. Formally, find nonnegative integers &amp;lt;math&amp;gt;k_1, k_2, ..., k_n&amp;lt;/math&amp;gt; that minimize &amp;lt;math&amp;gt;k_1 + k_2 + ... + k_n&amp;lt;/math&amp;gt; subject to &amp;lt;math&amp;gt;k_1 D_1 + k_2 D_2 + ... + k_n D_n = T&amp;lt;/math&amp;gt;, or determine that this is impossible.&lt;br /&gt;
* ''Counting problem'': Find the total number of different ways to make change for the target amount. Formally, count the number of tuples of nonnegative integers &amp;lt;math&amp;gt;(k_1, k_2, ..., k_n)&amp;lt;/math&amp;gt; that satisfy &amp;lt;math&amp;gt;k_1 D_1 + k_2 D_2 + ... + k_n D_n = T&amp;lt;/math&amp;gt;.&lt;br /&gt;
The former, the optimization problem, should be very familiar. It is a problem that cashiers solve when (for example) you hand them a five-dollar bill for a purchase of $3.44, and they have to find a way to give you back $1.56 in ''change'', preferably with as few coins as possible.&amp;lt;ref&amp;gt;The Canadians have a $2.00 coin, a $1.00 coin, a $0.25 coin, a $0.10 coin, a $0.05 coin, and a $0.01 coin. The solution to this problem in Canadian currency is one $1.00 coin, two $0.25 coins, one $0.05 coin, and one $0.01 coin.&amp;lt;/ref&amp;gt; It is a well-studied problem that is extensively treated in the literature. The counting problem is somewhat more exotic; it arises mostly as a mathematical curiosity, often in the form of the puzzle: &amp;quot;How many ways are there to make change for a dollar?&amp;quot;&amp;lt;ref&amp;gt;The denominations in circulation in the United States are the same as those in Canada, except for the absence of a $2.00 coin and the presence of a $0.50 coin. In United States currency, the answer is 293 if the trivial solution consisting of a single one-dollar coin is counted, or 292 if it is not.&amp;lt;/ref&amp;gt; It is also not often encountered in the literature, but it is discussed here because it occasionally appears in algorithmic programming competitions.&lt;br /&gt;
&lt;br /&gt;
==Discussion of complexity==&lt;br /&gt;
The corresponding decision problem, which simply asks us to determine whether or not making change is ''possible'' with the given denominations (which it might not be, if we are missing the denomination 1) is known to be [[NP-complete]].&amp;lt;ref&amp;gt;G. S. Lueker. (1975). ''Two NP-complete problems in nonnegative integer programming.'' Technical Report 178, Computer Science Laboratory, Princeton University''&amp;lt;/ref&amp;gt; It follows that the optimization and counting problems are both [[NP-hard]] (''e.g.'', because the result of 0 for the counting problem answers the decision problem in the negative, and any nonzero value answers it in the affirmative).&lt;br /&gt;
&lt;br /&gt;
However, as we shall see, a simple &amp;lt;math&amp;gt;O(nT)&amp;lt;/math&amp;gt; solution exists for both versions of the problem. Why then are these problems not in P? The answer is that the ''size'' of the input required to represent the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is actually the ''length'' of the number &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which is &amp;lt;math&amp;gt;\Theta(\log T)&amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; is expressed in binary (or decimal, or whatever). Thus, the time and space required by the algorithm is actually &amp;lt;math&amp;gt;O(n 2^{\lg T})&amp;lt;/math&amp;gt;, that is, exponential in the size of the input. (This simplified analysis does not take into account the sizes of the denominations, but captures the essence of the argument.) This algorithm is then said to be ''pseudo-polynomial''. No true polynomial-time algorithm is known (and, indeed, none will be found unless it turns out that P = NP).&lt;br /&gt;
&lt;br /&gt;
==Greedy algorithm==&lt;br /&gt;
Many real-world currency systems admit a [[greedy solution]] to the optimization version of the change problem. This algorithm is as follows: repeatedly choose the largest denomination that is less than or equal to the target amount, and ''use it'', that is, subtract it from the target amount, and then repeat this procedure on the reduced value, until the target amount decreases to zero. For example, with Canadian currency, we can greedily make change for $0.63 as follows: the largest denomination that fits into $0.63 is $0.25, so we subtract that (and thus resolve to use a $0.25 coin); we are left with $0.38, and take out another $0.25, so we subtract that again to obtain $0.13 (so that we have used two $0.25 coins so far); now the largest denomination that fits is $0.10, so we subtract that out, leaving us with $0.03; and then we subtract three $0.01 coins, leaving us with $0.00, at which point the algorithm terminates; so we have used six coins (two $0.25 coins, one $0.10 coin, and three $0.01 coins).&lt;br /&gt;
&lt;br /&gt;
It turns out that the greedy algorithm ''always'' gives the correct result for both Canadian and United States currencies (the proof is left as an exercise for the reader). There are various other real-world currency systems for which this is also true. However, there are simple examples of sets of denominations for which the greedy algorithm does ''not'' give a correct solution. For example, with the set of denominations &amp;lt;math&amp;gt;{1, 3, 4}&amp;lt;/math&amp;gt;, the greedy algorithm will change 6 as 4+1+1, using three coins, whereas the correct minimal solution is obviously 3+3. There are also cases in which the greedy algorithm will fail to make change at all (consider what happens if we try to change 7 using the denominations &amp;lt;math&amp;gt;{3, 4}&amp;lt;/math&amp;gt;). This usually does not occur in real-world systems because they tend to have denominations that are quite a bit more &amp;quot;spaced out&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Obviously, there is no greedy solution to the counting problem.&lt;br /&gt;
&lt;br /&gt;
==Dynamic programming solution==&lt;br /&gt;
The optimization problem exhibits optimal substructure, in the sense that if we remove any coin of value &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; from the optimal means of changing &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, then the set of coins remaining is an optimal means of changing &amp;lt;math&amp;gt;T - D_i&amp;lt;/math&amp;gt;. This is because if this were ''not'' so; that is, there existed a means of changing &amp;lt;math&amp;gt;T - D_i&amp;lt;/math&amp;gt; that used fewer coins than what we obtained by removing the coin &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; from our supposed optimal change for &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, then we could just add the coin &amp;lt;math&amp;gt;D_i&amp;lt;/math&amp;gt; back in and get change for the original amount &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; in fewer coins, a contradiction. Therefore, if we let &amp;lt;math&amp;gt;f(x)&amp;lt;/math&amp;gt; denote the minimal number of coins required to change amount &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, then we can write &amp;lt;math&amp;gt;f(x) = 1 + \min_i f(x - D_i)&amp;lt;/math&amp;gt;; we consider all possible minimal solutions to &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; minus one coin, and take the best one and add that coin back in to get minimal change for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. The base case is &amp;lt;math&amp;gt;f(0) = 0&amp;lt;/math&amp;gt;; obviously, 0 coins are required to make change for 0. See [[Dynamic_programming#Optimization_example:_Change_problem|the DP article]] for details and an implementation.&lt;br /&gt;
&lt;br /&gt;
TODO: counting problem&lt;br /&gt;
&lt;br /&gt;
==Notes and References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	</feed>