Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:31:49+00:00 2026-05-16T05:31:49+00:00

Rather than optimize anything, I want to list all the possible – including incomplete

  • 0

Rather than optimize anything, I want to list all the possible – including “incomplete” – packings of the knapsack. Of course, I could loop through all subsets of the set of objects and pick the ones satisfying the weight constraint (can be improved by placing an upper bound on the size of the subsets to look through), but I’d really like something more efficient.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:31:49+00:00Added an answer on May 16, 2026 at 5:31 am

    First sort your objects by weight. Then recursively pack the knapsack. If the smallest weight object not yet considered does not fit, or we have no objects remaining, then add the current knapsack to our list and return, else add the current knapsack to our list for each object in the list that fits put it in and try to pack the rest of the knapsack with objects heavier than the last object we packed.

    If we can pack more than one item of a given type then replace less than with less than or equal to.

    If we have multiple objects of the same weight we need to sort first by weight, then by some arbitrary order, and use that.

     PackKnapsack(knapsack, objects)
       add knapsack to list
       if objects is empty return
       if smallest object does not fit return
       for each object in order from smallest to largest
          if currentobject does not fit
             break
          PackKnapsack(knapsack + currentObject, objects heavier than current object)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been sold on mod_wsgi and apache rather than mod_python. I have all
Web applications that want to force a resource to be downloaded rather than directly
Rather than simply dumping the HTML into the page I want it to be
I want to codesign an .exe file using an API rather than running signtool.exe.
Rather than population said DOM object with an external page such as HTML CFM
Rather than scraping a Ruby version of this algorithm off the net I wanted
Has anyone used Lucene.NET rather than using the full text search that comes with
I'm developing an operating system and rather than programming the kernel, I'm designing the
(This is a question about the UI rather than the technology required to do
Does creating an object using reflection rather than calling the class constructor result in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.