<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: The 0-1 Knapsack Problem</title>
	<atom:link href="http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/feed/" rel="self" type="application/rss+xml" />
	<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/</link>
	<description>Just another programming weblog</description>
	<lastBuildDate>Wed, 11 Nov 2009 07:05:51 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Binish</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-431</link>
		<dc:creator>Binish</dc:creator>
		<pubDate>Wed, 04 Nov 2009 14:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-431</guid>
		<description>Thank U so very much .. this post was very helpful    in my studies ...</description>
		<content:encoded><![CDATA[<p>Thank U so very much .. this post was very helpful    in my studies &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nikhil</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-417</link>
		<dc:creator>nikhil</dc:creator>
		<pubDate>Mon, 28 Sep 2009 03:11:38 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-417</guid>
		<description>thx you its good</description>
		<content:encoded><![CDATA[<p>thx you its good</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nikhil</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-416</link>
		<dc:creator>nikhil</dc:creator>
		<pubDate>Mon, 28 Sep 2009 03:08:48 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-416</guid>
		<description>its cool thank you</description>
		<content:encoded><![CDATA[<p>its cool thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-393</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 09 Jul 2009 16:22:21 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-393</guid>
		<description>The max benefit is 17.

If you take 2 of 1, and 1 of 2.

Then you have weight 
3, 3, 4 = 10, and value
5, 5, 7 = 17</description>
		<content:encoded><![CDATA[<p>The max benefit is 17.</p>
<p>If you take 2 of 1, and 1 of 2.</p>
<p>Then you have weight<br />
3, 3, 4 = 10, and value<br />
5, 5, 7 = 17</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vhanded</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-366</link>
		<dc:creator>vhanded</dc:creator>
		<pubDate>Sat, 18 Apr 2009 02:34:18 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-366</guid>
		<description>yup, it is. The solution I posted up is bounded.</description>
		<content:encoded><![CDATA[<p>yup, it is. The solution I posted up is bounded.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aglock</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-365</link>
		<dc:creator>aglock</dc:creator>
		<pubDate>Fri, 17 Apr 2009 21:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-365</guid>
		<description>i am new to the knapsack problem 
but it looks like that the lrrh problem described is an unbound knapsack problem.</description>
		<content:encoded><![CDATA[<p>i am new to the knapsack problem<br />
but it looks like that the lrrh problem described is an unbound knapsack problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vhanded</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-360</link>
		<dc:creator>vhanded</dc:creator>
		<pubDate>Tue, 31 Mar 2009 07:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-360</guid>
		<description>//The code that I modified is here:

#include 

#define MAXWEIGHT 100

int n = 5;
int c[]={2,4,3,5,7};      //cost aka weight
int v[]={3,7,9,8,4};    //value  aka benefit
int W=15;               //maximum weight can take(bag size)
int main()
{
    int table[W][n];
    for(int i=0; i&lt;=W; i++)
    {
        for(int j=0; j&lt;n; j++)
        {
            table[i][j]=0;
        }
    }

    int a[W];   //this hold the maximum value that can can be obtained using at most i weight

    for(int i=0; i&lt;=W; i++)
    {
        a[i]=0;
    }

    for(int i=1; i&lt;=W; ++i)
    {
        for(int j=0; j&lt;n; ++j)
        {
            if((c[j]&lt;=i)&amp;&amp;(a[i]&lt;=(a[i-c[j]]+v[j]))&amp;&amp;table[i-c[j]][j]!=1)
            //c[j]&lt;=i, to allow only if selected weight bucket is less than i
            //(a[i]&lt;=(a[i-c[j]]+v[j]), to check if the previous weight bucket has closer value.
            //table[i-c[j]][j]!=1 is to prevent the items reuse.
            {
                for(int k=0; k=a[i])
                {
                    table[i][j]=1;
                }
                a[i]=newTotalBenefit;
            }
        }
    }

printf(&quot;\t&quot;);
for(int i=0; i&lt;n; i++)
{
    printf(&quot;%d &quot;,i);
}
printf(&quot;\n&quot;);
for(int i=0; i&lt;=W; i++)
{
    printf(&quot;%d\t&quot;, i);
    for(int j=0; j&lt;n; j++)
    {
        printf(&quot;%d &quot;,table[i][j]);
    }
    printf(&quot;\n&quot;);
}

    printf(&quot;\nmax benefit = %d&quot;, a[W]);
}


//hope it helps.</description>
		<content:encoded><![CDATA[<p>//The code that I modified is here:</p>
<p>#include </p>
<p>#define MAXWEIGHT 100</p>
<p>int n = 5;<br />
int c[]={2,4,3,5,7};      //cost aka weight<br />
int v[]={3,7,9,8,4};    //value  aka benefit<br />
int W=15;               //maximum weight can take(bag size)<br />
int main()<br />
{<br />
    int table[W][n];<br />
    for(int i=0; i&lt;=W; i++)<br />
    {<br />
        for(int j=0; j&lt;n; j++)<br />
        {<br />
            table[i][j]=0;<br />
        }<br />
    }</p>
<p>    int a[W];   //this hold the maximum value that can can be obtained using at most i weight</p>
<p>    for(int i=0; i&lt;=W; i++)<br />
    {<br />
        a[i]=0;<br />
    }</p>
<p>    for(int i=1; i&lt;=W; ++i)<br />
    {<br />
        for(int j=0; j&lt;n; ++j)<br />
        {<br />
            if((c[j]&lt;=i)&amp;&amp;(a[i]&lt;=(a[i-c[j]]+v[j]))&amp;&amp;table[i-c[j]][j]!=1)<br />
            //c[j]&lt;=i, to allow only if selected weight bucket is less than i<br />
            //(a[i]&lt;=(a[i-c[j]]+v[j]), to check if the previous weight bucket has closer value.<br />
            //table[i-c[j]][j]!=1 is to prevent the items reuse.<br />
            {<br />
                for(int k=0; k=a[i])<br />
                {<br />
                    table[i][j]=1;<br />
                }<br />
                a[i]=newTotalBenefit;<br />
            }<br />
        }<br />
    }</p>
<p>printf(&#8220;\t&#8221;);<br />
for(int i=0; i&lt;n; i++)<br />
{<br />
    printf(&#8220;%d &#8220;,i);<br />
}<br />
printf(&#8220;\n&#8221;);<br />
for(int i=0; i&lt;=W; i++)<br />
{<br />
    printf(&#8220;%d\t&#8221;, i);<br />
    for(int j=0; j&lt;n; j++)<br />
    {<br />
        printf(&#8220;%d &#8220;,table[i][j]);<br />
    }<br />
    printf(&#8220;\n&#8221;);<br />
}</p>
<p>    printf(&#8220;\nmax benefit = %d&#8221;, a[W]);<br />
}</p>
<p>//hope it helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miro</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-353</link>
		<dc:creator>Miro</dc:creator>
		<pubDate>Tue, 24 Mar 2009 11:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-353</guid>
		<description>Vhanded can you send me the modified program (c code) on my e-mail?? I would be very grateful :) it&#039;s very important here is my mail: misq51@o2.pl</description>
		<content:encoded><![CDATA[<p>Vhanded can you send me the modified program (c code) on my e-mail?? I would be very grateful :) it&#8217;s very important here is my mail: <a href="mailto:misq51@o2.pl">misq51@o2.pl</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miro</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-350</link>
		<dc:creator>Miro</dc:creator>
		<pubDate>Sat, 21 Mar 2009 10:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-350</guid>
		<description>can you write this part of the code? and the place were you must add it? thx</description>
		<content:encoded><![CDATA[<p>can you write this part of the code? and the place were you must add it? thx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vhanded</title>
		<link>http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-348</link>
		<dc:creator>vhanded</dc:creator>
		<pubDate>Fri, 20 Mar 2009 16:54:22 +0000</pubDate>
		<guid isPermaLink="false">http://compprog.wordpress.com/2007/11/20/the-0-1-knapsack-problem/#comment-348</guid>
		<description>For example, to reach weight 3, I added item 1; to reach weight 6, I added item 1 again... that&#039;s the problem.

To prevent it from reuse, I added a table to record down, if the item was used for a particular weight, put as 1, else 0.</description>
		<content:encoded><![CDATA[<p>For example, to reach weight 3, I added item 1; to reach weight 6, I added item 1 again&#8230; that&#8217;s the problem.</p>
<p>To prevent it from reuse, I added a table to record down, if the item was used for a particular weight, put as 1, else 0.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
