4 Dynamic Programming Consider the following problem based on the transformation of a sequence (or collection)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4 Dynamic Programming Consider the following problem based on the transformation of a sequence (or collection) of coloured disks. Assume that you have a very large collection of disks, each with an integer value representing the disk colour from the range [0, c]. For example, the colour mapping might be: 0-red, 1-yellow, 2-blue, 3-pink, ..., c-black. For a given sequence of coloured disks e.g., (0,1,2,3,4), at each time step (or iteration) you are only allowed to perform one of three basic operations: • remove one disk from the sequence - the disk you select can be any of the disks eg., (0,1,2,3,4) (0,1,3,4) • insert one disk at any position in the sequence - the disk you select to insert can be any colour in the range [0, c] e.g., (0,1,2,3,4)→ (0,1,9,2,3,4) • replace any single coloured disk in the sequence with a different coloured disk-the replacement disk can be any colour in the range [0, c e.g., (0,1,2,3,4) (0,1,2,3,9) Note: after multiple operations (or iterations), the length of sequence of disks may be different to the length of the starting sequence. We suggest that you represent each sequence of disks as an array. (a) [6 marks] Write a dynamic programming implementation for the function: TRANSFORM(A[0..n-1], B[0..m-1]) to calculate the minimum number of operations required to transform one given sequence of disks A[0..n-1] into another B[0..m-1]. For example, A[0, 1, 2, 3, 4] B[0, 1, 3, 5] requires at least two operations - remove 2; replace 4 by 5. Your function must be written in clear, unambiguous pseudo code. (Hint: consider approximate string search) (b) [2 marks] What is the time complexity of your algorithm? Justify your answer. 4 Dynamic Programming Consider the following problem based on the transformation of a sequence (or collection) of coloured disks. Assume that you have a very large collection of disks, each with an integer value representing the disk colour from the range [0, c]. For example, the colour mapping might be: 0-red, 1-yellow, 2-blue, 3-pink, ..., c-black. For a given sequence of coloured disks e.g., (0,1,2,3,4), at each time step (or iteration) you are only allowed to perform one of three basic operations: • remove one disk from the sequence - the disk you select can be any of the disks eg., (0,1,2,3,4) (0,1,3,4) • insert one disk at any position in the sequence - the disk you select to insert can be any colour in the range [0, c] e.g., (0,1,2,3,4)→ (0,1,9,2,3,4) • replace any single coloured disk in the sequence with a different coloured disk-the replacement disk can be any colour in the range [0, c e.g., (0,1,2,3,4) (0,1,2,3,9) Note: after multiple operations (or iterations), the length of sequence of disks may be different to the length of the starting sequence. We suggest that you represent each sequence of disks as an array. (a) [6 marks] Write a dynamic programming implementation for the function: TRANSFORM(A[0..n-1], B[0..m-1]) to calculate the minimum number of operations required to transform one given sequence of disks A[0..n-1] into another B[0..m-1]. For example, A[0, 1, 2, 3, 4] B[0, 1, 3, 5] requires at least two operations - remove 2; replace 4 by 5. Your function must be written in clear, unambiguous pseudo code. (Hint: consider approximate string search) (b) [2 marks] What is the time complexity of your algorithm? Justify your answer.
Expert Answer:
Answer rating: 100% (QA)
a Algorithm for TRANSFORM Function TRANSFORMA0n1 B0m1 1 Create a 2dimensional array C0n 0... View the full answer
Related Book For
Fundamentals of Financial Management
ISBN: 978-0324597707
12th edition
Authors: Eugene F. Brigham, Joel F. Houston
Posted Date:
Students also viewed these programming questions
-
Problem # 1 I asked you to prepare a 2-3-page report on how to benefit from creating a free online application and placing it on the Internet. You must explain how you can make a profit from the free...
-
In the training, a supervisor has asked you to do regular checking of combustion process. The checking is done by analyzing meter reading from instrument panel. The instrument panel for combustion...
-
11. Calculate the expected return and standard deviation for the risky portfolio on the CAL (with or without borrowing) and for the investor's complete portfolio on the CAL. 8(,1)% Std dev= 30 25 18...
-
Use the Internet to find a site that contains current IT industry news, information, and links. Write a brief description of you liked and didnt like.
-
When would an ABC classification inventory system be appropriate?
-
How does make determine whether a target needs to be rebuilt?
-
(Basic Pension Worksheet) The following defined pension data of Rydell Corp. apply to the year 2010. For 2010, prepare a pension worksheet for Rydell Corp. that shows the journal entry for pension...
-
b. A fence company is measuring a rectangular area in order to install a fence around its perimeter. If the length of the rectangular area is 130 yards and the width is 75 feet, what is the total...
-
The Sally Coffee Shop is considering closing one hour earlier in the evening through the week. Sally obtained the following data from a study taken last week of the number of customers between the...
-
Describe the primary characteristics for governmental and not-for-profit entities. How does this differ from the primary characteristics for business organizations? In your discussion, explain how...
-
Wade Ellis buys a new car for $16,135.79. He puts 10% down and obtains a simple interest amortized loan for the rest at 11 1/2 (a) Find his monthly payment. interest for four years. (Round your...
-
Bavarian sausage just issued a 7 year 8% coupon bond. the face value of the bond is 1,000 and the bond makes annual coupon payments. If the bond is trading at $1006.83, what is the bonds yield to...
-
Create a tornado diagram to review sensitivity resource costs where Resource Cost = Operations Cost+ Legal Cost+ HR Cost +Marketing Cost ClockWatch Project Optimistic Most Likely Pessimistic...
-
Describe the disparity between anabolic and catabolic reactions and elucidate their common integration within metabolic pathways.
-
Shrieves Casting Company is considering adding a new line to its product mix, and the capital budgeting analysis is being conducted by Sidney Johnson, a recently graduated MBA. The cost of new...
-
Nathan is 24 years old and works as an accountant in a salmon cannery in Alaska. His total wages for 2021 were $62,000. Federal income tax of $6,500 was withheld from his wages. His only other income...
-
Choose two matrices A and B with dimension 2 x 2. Calculate det A, det B, and det (AB). Repeat this process until you are able to discover how these three determinants are related. Summarize your...
-
How should the capital structure weights used to calculate the WACC be determined?
-
Explain in general terms what each of the following real options is and how it could change projects NPVs and their corresponding risk relative to what would have been estimated if the options had...
-
a. What are the four most fundamental factors that affect the cost of money, or the general level of interest rates, in the economy? b. What is the real risk-free rate of interest (r*) and the...
-
To test \(H_{0}: \sigma=50\) versus \(H_{1}: \sigma <50\), a random sample of size \(n=24\) is obtained from a population that is known to be normally distributed. (a) If the sample standard...
-
In Example 2 from Section 10.3, the quality-control engineer for M\&MMars tested whether the mean weight of fun-size Snickers was 20.1 grams. Suppose that the standard deviation of the weight of the...
-
(a) Determine the critical values for a right-tailed test of a standard population deviation with 18 degrees of freedom at \(\alpha=0.1\) level of significance. (b) Determine the critical values for...
Study smarter with the SolutionInn App