There are n trading posts numbered 1 to n, as you travel downstream. At any trading...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
There are n trading posts numbered 1 to n, as you travel downstream. At any trading post i, you can rent a canoe to be returned at any of the downstream trading posts j> i. You are given a cost array R(i, j) giving the cost of these rentals for 1i j n. We will have to assume that R(i,i) = 0 and R(i, j) = if i > j. For example, with n = 4, the cost array may look as follows: The rows are the sources (i-s) and the columns are the destinations (j's). 1 2 1 2 3 4 20 0 2 3 7 2 4 234 4 02 0 The problem is to find a solution that computes the cheapest sequence of rentals taking you from post 1 all the way down to post n. In this example, the cheapest sequence is to rent from post 1 to post 3 (cost 3), then from post 3 to post 4 (cost 2), with a total cost of 5 (less than the direct rental from post 1 to post 7, which would cost 7). 3 YOUR TASKS 3.1 BRUTE FORCE (4 points): Design a brute force solution to solve this problem. You need to print the cheapest solution, as well as the sequence. What is the asymptotic complexity of this algorithm? 3.2 DIVIDE AND CONQUER (7 points): Express the problem with a purely divide-and-conquer approach. Implement a recursive algorithm for the problem. Be sure to consider all sub-instances needed to compute a solution to the full input instance in the self-reduction, especially if it contains overlaps. As before, you need to print the solution, as well as the sequence. What is the asymptotic complexity of this algorithm? 3.3 DYNAMIC PROGRAMMING (7 points): Design a dynamic programming table for this problem. How is the table initial- ized? In what order will the table be filled? How would you use the table to find the cheapest sequence of canoe rentals from post 1 to post n? Implement the corresponding dynamic programming solution. Question 3: (20 marks) A person is trading his money in the stock exchange market. Assume that the daily price of a specific market along a certain period of time is given as follows: Price [200, 500, 800, 100, 300, 50] all in Dollar. This means that the price of the stock in the first day is 200$ and the day after which is mean the second day the price is going up to be $500 and so on until the end of the week or the list you are given. You are allowed to buy and sell the stock only once, which means that if you buy it on the first day then you will pay 200$ then if you decided to sell it on the third day then you will get $800 the your profit will be $600. Another example: prices (300, 450, 720, 90, 30, 50, 900, 500, 70% Output: Buying date: day 5, at the price of $30 selling date: day 7, at the price of $900 Maximum Profit: $870 1. You are requested to develop an algorithm to maximize the profit in single buy and sell. 2. Build your algorithm by using OUBUILD 3. Provide two screenshots with different outputs. Proof of correctness: stability Claim. In Gale-Shapley matching M*, there are no unstable pairs. Pf. Suppose that M* does not contain the pair h-s. Case 1: h never proposed to s. h prefers its Gale-Shapley partners' to s. h-s is not unstable, pair Case 2: h proposed to s. - hospitals propose in decreasing order of preference =>> s rejected h (right away or later) =>>> s prefers Gale-Shapley partner h' to h. h-s is not unstable pair students only trade up h-s' h'-s In either case, the pair h-s is not unstable. Gale-Shapley matching M* 12 There are n trading posts numbered 1 to n, as you travel downstream. At any trading post i, you can rent a canoe to be returned at any of the downstream trading posts j> i. You are given a cost array R(i, j) giving the cost of these rentals for 1i j n. We will have to assume that R(i,i) = 0 and R(i, j) = if i > j. For example, with n = 4, the cost array may look as follows: The rows are the sources (i-s) and the columns are the destinations (j's). 1 2 1 2 3 4 20 0 2 3 7 2 4 234 4 02 0 The problem is to find a solution that computes the cheapest sequence of rentals taking you from post 1 all the way down to post n. In this example, the cheapest sequence is to rent from post 1 to post 3 (cost 3), then from post 3 to post 4 (cost 2), with a total cost of 5 (less than the direct rental from post 1 to post 7, which would cost 7). 3 YOUR TASKS 3.1 BRUTE FORCE (4 points): Design a brute force solution to solve this problem. You need to print the cheapest solution, as well as the sequence. What is the asymptotic complexity of this algorithm? 3.2 DIVIDE AND CONQUER (7 points): Express the problem with a purely divide-and-conquer approach. Implement a recursive algorithm for the problem. Be sure to consider all sub-instances needed to compute a solution to the full input instance in the self-reduction, especially if it contains overlaps. As before, you need to print the solution, as well as the sequence. What is the asymptotic complexity of this algorithm? 3.3 DYNAMIC PROGRAMMING (7 points): Design a dynamic programming table for this problem. How is the table initial- ized? In what order will the table be filled? How would you use the table to find the cheapest sequence of canoe rentals from post 1 to post n? Implement the corresponding dynamic programming solution. Question 3: (20 marks) A person is trading his money in the stock exchange market. Assume that the daily price of a specific market along a certain period of time is given as follows: Price [200, 500, 800, 100, 300, 50] all in Dollar. This means that the price of the stock in the first day is 200$ and the day after which is mean the second day the price is going up to be $500 and so on until the end of the week or the list you are given. You are allowed to buy and sell the stock only once, which means that if you buy it on the first day then you will pay 200$ then if you decided to sell it on the third day then you will get $800 the your profit will be $600. Another example: prices (300, 450, 720, 90, 30, 50, 900, 500, 70% Output: Buying date: day 5, at the price of $30 selling date: day 7, at the price of $900 Maximum Profit: $870 1. You are requested to develop an algorithm to maximize the profit in single buy and sell. 2. Build your algorithm by using OUBUILD 3. Provide two screenshots with different outputs. Proof of correctness: stability Claim. In Gale-Shapley matching M*, there are no unstable pairs. Pf. Suppose that M* does not contain the pair h-s. Case 1: h never proposed to s. h prefers its Gale-Shapley partners' to s. h-s is not unstable, pair Case 2: h proposed to s. - hospitals propose in decreasing order of preference =>> s rejected h (right away or later) =>>> s prefers Gale-Shapley partner h' to h. h-s is not unstable pair students only trade up h-s' h'-s In either case, the pair h-s is not unstable. Gale-Shapley matching M* 12
Expert Answer:
Answer rating: 100% (QA)
Here are the solutions to the questions 1 Brute Force Algorithm 4 points Pseudocode bruteForceR n mi... View the full answer
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these finance questions
-
Capital Budgeting Criteria: Mutually Exclusive Projects A firm with a WACC of 10% is considering the following mutually exclusive projects: 0 1 2 3 4 5 Project 1 -$300 $75 $75 $75 $190 $190 Project 2...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
: (i) What data structures are maintained by the page manager. (ii) What happens when a machine performs a read operation to a page. (iii) What happens when a machine performs a write operation to a...
-
Use the Chain Rule to evaluate the partial derivative at the point specified. /u and /v at (u, v) = (1,1), where f(x, y, z) = x + yz, x = u + v, y = u + v, z , Z = uv
-
Write a user-defined function that plots a triangle and the circle that circumscribes the triangle, given the coordinates of its vertices. For the function name and arguments, use TriCirc (A, B, C)....
-
Refer to Exercise 13. a. Compute the quantity s =MSE, the estimate of the error standard deviation . b. Assuming s to be the error standard deviation, find the sample size necessary in each treatment...
-
Brown Oil Company is the operator of Lease A and Lease B and has a 60% WI in each lease. A piece of equipment, which originally cost $30,000, is transferred from Lease A to Lease B. The current...
-
Here are the 2013 and 2014 (incomplete) balance sheets for Newble Oil Corp. a. What was owners' equity at the end of 2013 and 2014? b. If Newble paid dividends of $100 in 2014 and made no stock...
-
7) reflection across y=-1 4y A) B) C) W D) 43 P
-
! Invertir $1,500,000 en la iniciativa de Sistemas de Soportede Canal de TQM aumentar como mnimo la demanda de sus productosen un 1.7% en esta y en todas las rondas futuras. (Consulte la hojade 1...
-
A corporation has? 3,000 shares,? 10% preferred stock of? $50.00par preferred? stock, and? 6,000 shares of common stockoutstanding. The net income for the year is? $290,000. Calculateearnings per...
-
Madeline Manufacturing Inc. s current stock price is $ 4 0 per share. Call options for this stock exist that permit the holder to purchase one share at an exercise price of $ 3 0 . These options...
-
Analyzing a company for its investment potential In its annual report, WRM Athletic Supply, Inc. includes the following five-year financial summary: WRM ATHLETIC SUPPLY, INC. Five-Year Financial...
-
RFP to Determine Consumers' Perceptions of Purchasing Multi-Purpose Cleansing and Facial Device The use of skincare devices is on the rise, although only a few Canadians have enjoyed the experience...
-
Marie passes by Cody's property every day to get to work. On a hot summer day while Marie was walking back from work, she noticed that Cody's lawn sprinkler was on. Wanting to cool down a bit, Marie...
-
The following data compare women's responses to a survey about child responsiveness. The first group are women who do not have children and the second group are women who do have children. Answer...
-
Currently, there are five concepts of food stands, including: hot dogs, soft pretzels, turkey legs, sandwich wraps, and funnel cakes. This approach will double the existing number of food stands...
-
Is outsourcing by U.S. firms to foreign countries beneficial to the U.S. economy? Weigh the pros and cons, and offer your conclusions.
-
a. The dollar is presently worth .8 euros. What is the direct exchange rate of the euro? b. The direct exchange rate of the euro is presently valued higher than it was last month. What does this...
-
Assume that the Polish currency (called zloty) is worth $.32. The U.S. dollar is worth .7 euros. A U.S. dollar can be exchanged for 8 Mexican pesos. Last year a dollar was valued at 2.9 Polish zloty,...
Study smarter with the SolutionInn App