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

  Detect david alleged industrial espionage

What steps might have been taken to detect David's alleged industrial espionage? What steps might have been taken to prevent his perpetrating such an offense?

  Calculate the matrix determinant value

The matrix coef has exactly four columns and three rows. The function should return a row vector s that contains solution values each of which satisfies the equation below as x, y and z. You are allowed to use det to calculate the matrix determina..

  Parameter and return the number of odd nodes

Write a "count odds" function that will take a list as a parameter and return the number of odd nodes in the list.

  Describe the hashing security mechanism

Please describe the hashing security mechanism and its relationship to the encryption mechanism.

  Write a function to simulate the game show problem

Write a function to simulate the game show problem. Your function should randomly select locations for the prizes, select a door at random chosen by the contestant, and then determine whether the contestant would win or lose by sticking with the o..

  Identify one example of a procurement

1. Identify one example of a procurement (good or service) and a related risk, and how you might manage that risk during the procurement process.

  Display the value of element 6 of array f

Initialize each of the five elements of one-dimensional integer array g to 8.

  Determining fixed asset book value

The balance in the equipment account is $3,150,000, and the balance in the accumulated depreciation-equipment account is $2,075,000.

  About three different views of simulation quality

discusses methods to assess the quality of simulations. You learned about three different views of simulation quality.

  Natural languages and high-level programming languages

W?hat are some of the ways pseudocode overcomes the problems with natural language and high-level programming languages in regards to representing algorithms?

  What effect does this limit have on users

Some operating systems have a tree-structured file system but limit the depth of the tree to some small number of levels. What effect does this limit have on users? How does this simplify file system design (if it does)?

  Focuseded on effective use of online analytical processing

Focused on effective use of Online Analytical Processing (OLAP). Provide an example of an organization that has been successfully using OLAP in its operations.

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