Explain the runtime of the dynamic programming algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM132958989

Question 1: Recall the FOLDS AND CUTS problem from Assignment 2, where you are given a rectangular strip of paper P of length t with n ≥ 0 vertical folds, located at distances f1, f2 ... fn, A from the left end of P. Let fn+1 = 1. In the "dual" version of the problem, you are also given a nonnegative integer k. You want to cut P along exactly k < n folds, such that the maximum length of the k + 1 resulting strips is as short as possible. We'll denote this length by L(n, k).

More generally, for any i in the range [01..n], let Pi denote the strip of paper of length fi+i that has folds at distances f1, f2,f3 , fi. If we cut Pi, along exactly j folds, where 0 ≤ j ≤ i, such that the maximum length of the j + 1 resulting strips is as short as possible, we denote the resulting maximum length by L(i, j).

For example, if f1, f2, ....fi are 1,3,7, respectively, f4 = t = 10, and k = 2 then cutting at 3 and 7 is optimal, resulting in a max length L(3, 2) = 4. Also for this example, L(2, 1) = L(2, 2) = 4, while L(2,0) = 7.
1. When k < n, explain why L(n, k) ≤ l.
2. When k < n, explain why L(n, k) ≥ l/ l/k+1 .
3. Write a recursive definition of L(i, j) when 0 ≤ j ≤ i. You do not need to provide a justification for your recurrence.
4. Using your recurrence, give a memoized algorithm for computing L(n, k) .
5. Explain the runtime of your algorithm.

A rectangular strip of paper P of length £ has n vertical folds, located at distances f1, f2, .....fn , fn from the left end of P. We'll let 10 = 0 and fn+i = 1, and assume that all of the fi are distinct. See Figure ??.

For a given positive M, you want to cut P along a minimum number of folds so that the resulting strips {Si, ... , sk} each have length at most M. You can assume that M > fil4 - fi, for any i, 0 ≤ i ≤ n.

Question 2: Olaf has a collection of m types of ornaments, each with a unique colour (labelled from 1 to m), and a tree T with n vertices. He is very peculiar about decorating the tree. Each vertex v can be assigned an ornament of colour cv between integers 4 and I.,. In addition, to maximize the contrast between two ornaments along a single edge, he would like the sum of icu - c„) across all edges uv in T, or the beauty of T, to be as large as possible. The beauty of a tree with just one node is 0.

1. Show that an optimal assignment of ornaments exist such that either cv = 4 or ri, for every v.

2. Let BEAuTY(vre) denote the maximum beauty of v's subtree if ce, = 4 and let BEAUTY(V, r) denote the maximum beauty of v's subtree if cv = rv. Provide recurrences for BEAUTY(V, .e) and BEAUTY(V, r) (these recurrences can depend on each other), and give the expression for the maximal beauty of T.

3. Explain the runtime of the dynamic programming algorithm based on your recur¬rence. (You don't need to write the dynamic programming algorithm.)

Question 3: You are the manager of the Abbotsford branch of a large multinational company, and your company just bought out a small business based in Brampton, Ontario. However, your company has not found a manager for the Brampton branch yet, so they have asked you to oversee both branches until the end of the year. There are n days remaining in the year.

Because you will be spending a fair amount of time in Brampton, you have determined that it will be more convenient to stay in hotels in both cities, rather than continuing to rent your apartment in Abbotsford. You cannot stay in either location for more than 7 days because you do not want to be away from either branch for too long. You must determine how to split your time between Abbotsford and Brampton in a way that minimizes the total cost of your hotels and flights.

The cost of your flight/hotel depends on the day (weekends/holidays might be more expensive, or there might be promotions on certain days) and the city. You are given four arrays that provide the cost of the hotels and flights for each day.

The arrays fA, hi., hA, and hB, each of length n, are defined as follows:

fA[i] is the cost of flying to Abbotsford on day i
fs[i] is the cost of flying to Brampton on day i
hA [i] is the cost of staying in a hotel in Abbotsford on day i

hB [i] is the cost of staying in a hotel in Brampton on day i

Question 4: You are looking to minimize the cost of accommodations plus flights, subject to the constraint that you cannot spend more than 7 days in one location. You can assume that your flights are always in the morning (so if you are flying between cities on day i, you only have to pay for a hotel in your destination city that day).

Let CA [i] be the lowest possible value of the objective function for days 1 to i, assuming you are staying in Abbotsford on day i. Similarly, let CB[i] be the lowest possible value of the objective function for days 1 to i, assuming you are staying in Brampton on day i. In either case, assume that you are staying in Abbotsford on day 0. The solutions to Tutorial 7 provide recurrences for these values.

1. Using the recurrences from Tutorial 7, write pseudo-code for an iterative dynamic programming algorithm that takes fA, fB, hA and hB as input and populates the arrays CA and CB for every value 1 < i < n. Note: it is acceptable to leave min() operations in your pseudo-code instead of writing out an inner loop.

2. State the running time of your algorithm from part 1 as a function of n. No justification needed.

Reference no: EM132958989

Questions Cloud

Necessary for effective and efficient project management : What leadership skill do you find most necessary for effective and efficient project management? Why? Include references.
Compute what will the price be four years from now : A 20-year, $1,000 par value bond has a 6% annual payment coupon. If the yield to maturity remains at its current rate, what will the price be 4 years from now?
Importance of recruitment and selection in business : 'The importance of recruitment and selection in business and organisations is arguably the easiest concept to grasp in the practice of HRM' (Hinton, Woods and Z
Compute npv for both projects for bahamas recreation corp : Compute the incremental IRR for the cash flows. Cash flows on two mutually exclusive projects for the Bahamas Recreation Corporation
Explain the runtime of the dynamic programming algorithm : Explain the runtime of the dynamic programming algorithm based on your recur¬rence. (You don't need to write the dynamic programming algorithm.)
Calculate sandhill earnings per share : Calculate Sandhill's 2020 earnings per share. During 2020, Sandhill has not declared or paid any dividend on 107,000 non-cumulative preferred shares.
Why should a company not recognise a profit : Why should a company not recognise a profit when they purchase inventory? Because profit is a function of sales and cost of sales, not purchases
Find what is cost of common equity for summerdahl resort : What is the cost of common equity? The stock is expected to pay a dividend of $2.00 a share at the end of the year (D1 = $2.00).
Prepare the ending balances for plan assets : Determine the pension expenses recognized in 2020. Prepare the ending balances (31 December 2020) for plan assets, PBO, and calculate net pension liability.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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