Find the value of the optimal plan

Assignment Help JAVA Programming
Reference no: EM131449653

Question 1. Write a program to solve the Longest Common Subsequence problem using dynamic programming as discussed in class. For example, if the input is X = ABCBDAB and Y = BDCABA, then the output of your program should be BCBA.

Question 2. Suppose you need to create a work plan, and each week you have to choose a job to undertake. The set of possible jobs is divided into low-stress and high-stress jobs.

If you select a low-stress job in week i, then you get a revenue of li dollars; if you select a high-stress job, you get a revenue of hi dollars. The catch, however, is that in order for you to take on a high-stress job in week i, it's required that you rest in weeki - 1 because you need a full week of prep time to get ready for the stress level (It's okay to choose a high-stress job in week 1.) On the other hand, you can take a low-stress job in weeki even if you have done a job (of either type) in week i-1.

So, given a sequence of n weeks, a plan is speci?ed by a choice of "low-stress", "high-stress" or "none" for each of the n weeks, with the constraint that if "high-stress" is chosen for week i> 1, then "none" must be chosen for week i - 1. The value of the plan is determined in the natural way; for each i, you add li to the value if you choose "low-stress" in week i, and you add hi to the value if you choose "high-stress" in week i. (You add 0 if you choose "none" in week i.)

Example: Suppose n=4, and the values of li and hiare given by the following table. Then the plan of the maximum value would be to choose "none" in week 1, a high stress job in week 2, and low-stress jobs in weeks 3 and 4. The value of this plan would be

i

Week 1

Week 2

Week 3

Week 4

l

10

1

10

10

h

5

50

5

1

Design a dynamic programming algorithm to find the value of the optimal plan. Implement your algorithm using any programming language you prefer.

Verified Expert

The task was to implement the concept of dynamic programming in Computer science. First problem was to write code for longest common sub-sequence problem,also called LCS. Second problem was to design an algorithm for a job problem using dynamic programming and the code for it.Both were successfully implemented.

Reference no: EM131449653

Questions Cloud

Justify the nash equilibrium conditions : Exercise: (Nash demand game)* Consider the problem of dividing a pie between two players. If we let x and y denote player l and player 2 payoffs.
Calculate the set of daily returns : Calculate the set of daily returns that correspond to these daily price series - Based on your results in Part d, which stock appears to be the riskiest?
What is the function of a magistrate : What is the function of a magistrate? List the requirements for becoming a magistrate in your state of residence. Do you agree with those qualifications?
Describe edgeworth duopoly : There are two identical firms producing a homogeneous good whose demand curve is q = 100 - p. Firms simultaneously choose prices.
Find the value of the optimal plan : Design a dynamic programming algorithm to find the value of the optimal plan. Implement your algorithm using any programming language you prefer.
What is the managers expected hedge price : What is the manager's "expected hedge price?" Was the cooperatives expected hedge price equal to their realized hedge price? If not, why
Significance of the current data is for the economy : Explain what each of these economic indicators measures and what the significance of the current data is for the economy.
Cause the price of heating oil to increase : What other factors could cause the price of heating oil to increase?
Examine the components such as liquidity of debt : Examine the components, such as liquidity of debt, equity markets, existence of some form of market exchange, and regulatory body.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Display all of the elements of the arraylist

Once the user does this (hits enter without typing anything), the program will display all of the elements of the ArrayList, both the index and String values, in a table. It will do this via a single loop.

  Create a hang man type program

Create a hang man type program - create the full final picture image, and then rub out a piece and save it as a different filename, then rub out another part and save it as a different name.

  World data app

Prepare WorldDataApp project. It implements the NameIndex portion, including creating it in SetupProgram, and searching, viewing and updating it in UserApp program.

  Write a complete java class called diffcubes

Write a complete Java class called DiffCubes that uses a Scanner reads in two int values from the console. Using these values, the program should find the difference between the cubes of the two values and write the result to the screen

  Prepare demo program that implements all of above method

Specify, design, and implement a class that can be used in a program that simulates a combination lock.

  Create a class safestack that implements a stack of strings

Create a class SafeStack that implements a stack of strings

  Write a program that prompts a user to enter a us dollar

Write a program that prompts a user to enter a US dollar amount. Output a table similar to the one in the example below. The second prompt should ask the user to enter a 1 to convert to euros, a 2 to convert to pounds and a 3 to convert to ruble..

  What is the paintcomponent method how is it used in java

q1. what is the paintcomponent method? how is it used in java graphics? how does a program intentionally cause the

  Design a payroll class with the fields

Write a constructor that initializes these fields as well as accessor and mutator methods - Demonstrate the class in a program that contains a Car object, and then calls the accelerate method five times.

  Write a program that asks for the speed of a vehicle

Write a program that asks for the speed of a vehicle (in miles-per-hour) and the number of hours it has traveled.

  Assignmentwrite a gui-based application that allows a user

assignmentwrite a gui-based application that allows a user to play a simple trivia game. the game should have 5

  Run both c++ and java versions of your program

In C++, create an Exception class, and a DivideByZero sub-class that takes a string for its constructor, and use this in the try-catch mechanism. In Java, use the division by zero exception object.

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