Problem based on dynamic programming

Assignment Help Basic Computer Science
Reference no: EM132494204

Question 1 You are carrying a backpack that can only hold a limited amount of weight. Journeying through a cave you discover a pile of hidden treasure. Unfortunately, you can't carry it all with you. Select the items that have the greatest value such that the items you choose don't exceed a specified weight limit.

(a) You might consider a solution to the problem based on dynamic programming. An example of what your driver code *might* look like in your main function follows. You may choose how to format your output.

//Main program C++
int main()
{
//How many rupees is each treasure worth
int value [] = {210,220,180,120,160,170,90,40,60,10};

//How heavy is each piece of treasure
int weight [] = {15,12,10,9,8,7,5,4,3,1};


//How strong are you
// i . e. how much weight can you carry?
int W =26;
int n =10;

//Output the value in rupees of what you're able to carry
//Your output for this example should be 520
std :: cout << knapsack (weight, value, n, W) << std::endl;
return 0;
}

Reference no: EM132494204

Questions Cloud

What conversion strategy would you use : Suppose that you are installing a new room reservation system for your university that tracks which courses are assigned to which rooms.
Determining the operating system : What kinds of inconsistency can take place if the system is interrupted between the multiple operations necessary to complete the operation of creating a new fi
Explain briefly what super is with a simple example : Explain briefly what super is with a simple example. (Remember this is a 5 point question. So should spend maximum 5 minutes on this.
Produce an erd for a real estate firm : Produce an ERD for a real estate firm that lists property for sale. Also produce a definition for each entity type, attribute, and relationship on your diagram
Problem based on dynamic programming : You are carrying a backpack that can only hold a limited amount of weight. Journeying through a cave you discover a pile of hidden treasure.
How to create a flowchart : How to create a flowchart (Flowgorithm) to allow the user to enter two values. These values represent age and income, respectively
Write c program that stores lists of names : Write C program that stores lists of names (the last name first, then first name) and ages in parallel arrays and sorts the names into alphabetical
Powerful feature of windows server : Group policy is a powerful feature of Windows Server. It provides to automation and the ability to control desktop and server settings
Three levels of severity for problems : When using the Best Practices Analyzer (BPA) for Server roles, what are the three levels of severity for problems?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd