i  used this code but its giving me segmentation fault.
 vector<int>ans;//maintains the list of selected objects
    for(int x=t-1;x>0;x--)//t is the no. of objects
    {   if(knap[x][tt]!=knap[x-1][tt])//tt is the capacity of knapack
        {
           ans.push_back(ar[x].index);
            tt=tt-ar[x].value;

        }
    }

        if(knap[0][tt]>0)
            ans.push_back(ar[0].index);

On Tue, Jun 22, 2010 at 7:47 AM, ANUJ KUMAR <kumar.anuj...@gmail.com> wrote:
> How can i maintain the list of objects selected in the knapsack problem.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to