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 7075369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:09+00:00 2026-05-28T06:10:09+00:00

I watched Dynamic Programming – Kapsack Problem (YouTube) . However, I am solving a

  • 0

I watched Dynamic Programming – Kapsack Problem (YouTube). However, I am solving a slightly different problem where the constraint is the budget, price, in double, not integer. So I am wondering how can I modify that? Double is “continuous” unlike integer where I can have 1,2,3 …. I don’t suppose I do 0.0, 0.1, 0.2 …?

UPDATE 1

I thought of converting double to int by multiply by 100. Money is only 2 decimal places. But that will mean the range of values will be very large?

UPDATE 2

The problem I need to solve is:

Items have a price (double) & satisfaction (integer) value. I have a budget as a constraint and I need to maximize satisfaction value.

In the youtube video, the author created two 2d array like int[numItems][possibleCapacity(weight)]. Here, I can’t as budget is a double not integer

  • 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-28T06:10:09+00:00Added an answer on May 28, 2026 at 6:10 am

    If you want to use floating point numbers with arbitrary precision (i.e., don’t have a fixed number of decimals), and these are not fractions, dynamic programming won’t work.

    The basis of dynamic programming is to store previous results of a calculation for specific inputs. Therefore, if you used floating point numbers with arbitrary precision, you would need practically infinite memory for each of the possible floating point numbers and, of course, do infinite calculations, something that is impossible and non-optimal.

    However, if these numbers have a fixed precision (as with the money, which only have two decimal numbers), you can convert these into integers by multiplying them (as you’ve mentioned), and then solve the knapsack problem as usual.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently watched this youtube tutorial on the Null Object design pattern. Even though
I've watched this video from Google I/O 2009: http://www.youtube.com/watch?v=AgaL6NGpkB8 where Brett shows microblogging example.
I watched the YouTube presentation Tech Talk: Linus Torvalds on git a few weeks
I watched some videos, demos of Roo and I kind of liked it. However
I watched the Stanford online video lecture about java programming by Mehran Sami. In
so I watched this video on youtube ( http://www.youtube.com/watch?v=l_PLHuhlAJU ) on how to make
I watched a little introduction into ASP.NET Dynamic Data, and I noticed this option
Recently i watched a tutorial from youtube ( http://www.youtube.com/watch?v=8mwKq7_JlS8 ) The boy is typing
I just watched this funny YouTube Video about unit testing (it's Hitler with fake
I have watched a lot of youtube videos about binary code, but I don't

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.