You have been assigned to organize the first annual CPP CS Department canoe trip down the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You have been assigned to organize the first annual CPP CS Department canoe trip down the Los Angeles River. Canoes are available for rent at a sequence of n trading posts along the river, numbered 0, 1,..., n-1. The trip begins at post 0 and ends at post n - 1. However, individuals do not have to keep the same canoe for the entire trip; one can stop at any post, drop off the canoe used to reach that post, and rent another canoe. One may make as many stops on the river as desired. All canoe rental costs are positive integers. There is no added charge for exchanging canoes at a post. Travel down the river is one-way (downstream). For all pairs (a, b) with a <b, the cost of renting a canoe at post a and dropping it off at post b is given by a two-dimensional array C[a, b]. A sample cost matrix is shown below (with n= = 4). 0 1 2 3 01 2 3 10 15 50 40 20 35 Since most of those participating in the canoe trip are students, there is significant interest in finding the minimum cost sequence of canoe rentals. In the example above, the optimal solution is to rent a canoe between posts 0 and 1, and another canoe between posts 1 and 3, for a total cost of 30. Write a Java program which takes as input the name of a file in the current directory. The first line of the file will contain an integer n, giving the number of posts along the river. The remaining n 1 lines of the file will contain the integers of the cost matrix, delimited by white space, omitting the unnecessary entries. For example, the matrix shown above could be represented by the following data file: 4 10 15 50 40 20 35 (Note that white space is not significant in the file.) Using a dynamic programming algorithm, your program will then compute the optimal costs of traveling between any two posts (i, j) where i <j. The goal is to determine the optimal cost for (0, n − 1). After performing that calculation, your program will print the optimal cost matrix: i.e. the optimal cost between any two posts (i, j) for all values 0 ≤ i ≤j≤n-1. Additionally, your program will print the actual sequence of rentals to be used for the route between posts 0 and n − 1 (not just its optimal cost). - Your program should use "good style". See the separate handout on style requirements for CS3310 programs. In particular, note that you should describe the algorithms you implement in sufficient detail to demonstrate your deep understanding of the algorithms in question. Additionally, you should create the following ordinary text files: ● README: Information on how to compile and run your program. • ANALYSIS: An analysis of your program, including: - A description of the (recursive) formula used to calculate the optimal costs be- tween posts A theoretical analysis of the run time of your program, formula Note that an empirical timing analysis is not required. based upon that recursive You have been assigned to organize the first annual CPP CS Department canoe trip down the Los Angeles River. Canoes are available for rent at a sequence of n trading posts along the river, numbered 0, 1,..., n-1. The trip begins at post 0 and ends at post n - 1. However, individuals do not have to keep the same canoe for the entire trip; one can stop at any post, drop off the canoe used to reach that post, and rent another canoe. One may make as many stops on the river as desired. All canoe rental costs are positive integers. There is no added charge for exchanging canoes at a post. Travel down the river is one-way (downstream). For all pairs (a, b) with a <b, the cost of renting a canoe at post a and dropping it off at post b is given by a two-dimensional array C[a, b]. A sample cost matrix is shown below (with n= = 4). 0 1 2 3 01 2 3 10 15 50 40 20 35 Since most of those participating in the canoe trip are students, there is significant interest in finding the minimum cost sequence of canoe rentals. In the example above, the optimal solution is to rent a canoe between posts 0 and 1, and another canoe between posts 1 and 3, for a total cost of 30. Write a Java program which takes as input the name of a file in the current directory. The first line of the file will contain an integer n, giving the number of posts along the river. The remaining n 1 lines of the file will contain the integers of the cost matrix, delimited by white space, omitting the unnecessary entries. For example, the matrix shown above could be represented by the following data file: 4 10 15 50 40 20 35 (Note that white space is not significant in the file.) Using a dynamic programming algorithm, your program will then compute the optimal costs of traveling between any two posts (i, j) where i <j. The goal is to determine the optimal cost for (0, n − 1). After performing that calculation, your program will print the optimal cost matrix: i.e. the optimal cost between any two posts (i, j) for all values 0 ≤ i ≤j≤n-1. Additionally, your program will print the actual sequence of rentals to be used for the route between posts 0 and n − 1 (not just its optimal cost). - Your program should use "good style". See the separate handout on style requirements for CS3310 programs. In particular, note that you should describe the algorithms you implement in sufficient detail to demonstrate your deep understanding of the algorithms in question. Additionally, you should create the following ordinary text files: ● README: Information on how to compile and run your program. • ANALYSIS: An analysis of your program, including: - A description of the (recursive) formula used to calculate the optimal costs be- tween posts A theoretical analysis of the run time of your program, formula Note that an empirical timing analysis is not required. based upon that recursive
Expert Answer:
Answer rating: 100% (QA)
Here is the Java program that you requested import javaioFile import javaioFileNotFoundException import javautilScanner public class CanoeTrip private ... View the full answer
Related Book For
Horngrens Financial And Managerial Accounting The Financial Chapters
ISBN: 9780134486840
6th Edition
Authors: Tracie L. Miller Nobles, Brenda L. Mattison, Ella Mae Matsumura
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
1. Hannah is applying for a life policy on her girlfriend Sarahs life. The policy is $500,000 and carries a large premium. Hannah is the main earner, so she is concerned about not being able to pay...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Assignment: Based on your reading and analysis of the case study above, address the following items in a detailed essay response of approximately 600 words. Each number below should be addressed...
-
Argyle is a large, vertically integrated firm that manufactures sweaters from a rare type of wool produced on its sheep farms. Argyle has adopted a strategy of selling wool to companies that compete...
-
Bring out the impact of corporate reorganisations on HRM.
-
5 percent interest per month. The sterilizer was delivered on August 23, 1996. The last payment was received on April 21, 1998. At the time of the last payment, the defendant still owed the plaintiff...
-
(Retained Earnings Statement) Eddie Zambrano Corporation began operations on January 1, 2001. During its first 3 years of operations, Zambrano reported net income and declared dividends as follows....
-
Let n and m be positive integers with n m 1. (a) (9 points) How many different m-word sentences can be constructed using an al- phabet of n letters where each of the letters appears exactly once? A...
-
Obtain the Target Corporations annual report at http://investors.target.com using the instructions in Appendix B, and use it to answer the following questions: a. What was Targets net income for 2016...
-
Steel Door Co. produces two types of steel doors, Door 1 and Door 2, in its three work shops: Shop 1 produces plastic parts, and Shop 2 produces wood parts. Shop 3 is dedicated to producing steel...
-
Identify potential liability risks associated with not-for-profit boards and why would you consider them liability risks? (200-300 words)
-
Q1 What are inventories? Why are they important to manufacturing companies? Q2 What are the responsibilities of inventory management? Q3 What is aggregate inventory management?
-
On December 1st of the current year, Daughters Inc. borrowed money at the bank by signing a 90 day non-interest bearing note for $40,000 that was discounted at 12%. What would be the amount of...
-
Josh Luber Why sneakers are a great investment 33 unread replies.33 replies. Josh Luber is a "sneakerhead," a collector of rare or limited sneakers. With their insatiable appetite for exclusive...
-
Critically explain why the case of Paris v Stepney Borough Council (1950) BC [1951] HL may relate to the Equality Act 2010?
-
Capital sells its services to customers on account. The December 31, 2021 balance sheet disclosed the following: Current Assets: Accounts Receivable, net of allowance for uncollectible accounts of...
-
Explain the differences and similarities between fringe benefits and salary as forms of compensation.
-
This problem continues the Canyon Canoe Company situation from Chapter 2. You will need to use the unadjusted trial balance and posted T-accounts. At December 31, the business gathers the following...
-
Money Man Investments completed the following transactions during 2018: Jan. 14 Purchased 400 shares of Technomite stock, paying $56 per share. The investment represents 25% ownership in Technomite's...
-
The Accounts Receivable balance for Lake, Inc. at December 31, 2017, was $20,000. During 2018, Lake earned revenue of $454,000 on account and collected $325,000 on account. Lake wrote off $5,600...
-
Suppose that in September 2013 a company takes a long position in a contract on May 2014 crude oil futures. It closes out its position in March 2014. The futures price (per barrel) is \($88.30\) when...
-
Explain how the control variate technique is implemented.
-
A company wishes to hedge its exposure to a new fuel whose price changes have a 0.6 correlation with gasoline futures price changes. The company will lose $1 million for each 1 cent increase in the...
Study smarter with the SolutionInn App