Consider the best array slice problem: Given an array A of n integers, indexed from 0...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the best array slice problem: Given an array A of n integers, indexed from 0 to n - 1, find indices and r (with ≤r) that maximize the sum T ΣA[i]. i=l When >r, we evaluate this sum as zero. For example, with the input A = [3,-9, 4, -2, 6, -3, -1, 10, -5, 1, -3, 6], the output should be (2,7), because the greatest possible sum is A[2] + A[3] + A[4] + A[5] + A[6] + A[7] 4+(-2) +6+(-3)+(-1)+10. Best slices are not necessarily unique, and if the array entries are all negative, then the best slices will have l>r. Notice that a best slice could be in the first half in the array (l<r <n/2), in the second half of the array (n/2 ≤ ≤r), or split between the two halves (l<n/2 ≤r). (a) Design a O(n)-time algorithm to find the best slice that is split between the two halves. (b) Design a O(n log n)-time divide-and-conquer algorithm to find the overall best slice. Consider the best array slice problem: Given an array A of n integers, indexed from 0 to n - 1, find indices and r (with ≤r) that maximize the sum T ΣA[i]. i=l When >r, we evaluate this sum as zero. For example, with the input A = [3,-9, 4, -2, 6, -3, -1, 10, -5, 1, -3, 6], the output should be (2,7), because the greatest possible sum is A[2] + A[3] + A[4] + A[5] + A[6] + A[7] 4+(-2) +6+(-3)+(-1)+10. Best slices are not necessarily unique, and if the array entries are all negative, then the best slices will have l>r. Notice that a best slice could be in the first half in the array (l<r <n/2), in the second half of the array (n/2 ≤ ≤r), or split between the two halves (l<n/2 ≤r). (a) Design a O(n)-time algorithm to find the best slice that is split between the two halves. (b) Design a O(n log n)-time divide-and-conquer algorithm to find the overall best slice.
Expert Answer:
Answer rating: 100% (QA)
To solve the best array slice problemwe can use the ... View the full answer
Related Book For
Algebra Graduate Texts In Mathematics 73
ISBN: 9780387905181
8th Edition
Authors: Thomas W. Hungerford
Posted Date:
Students also viewed these programming questions
-
A company provides the following information related to its inventory. Inventory Number of Units Unit Cost Unit NRV Item A 3 , 8 0 0 $ 5 2 $ 4 6 Item B 4 , 2 0 0 2 8 3 0 Item C 2 , 5 0 0 3 4 3 1 Item...
-
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...
-
Gagnon's Autobody Ltd. repairs and paints automobiles after accidents. Explain how the basic statement of financial position accounts of assets, liabilities, and shareholders' equity would be...
-
Point A moves uniformly with velocity v so that the vector v is continually aimed at point B which in its turn moves rectilinearly and uniformly with velocity u < v. At the initial moment of time v u...
-
A horticulturalist at a large research institution designs a study to evaluate the effect on tomato yields of water loss due to transpiration. She decides to examine four levels of shading of the...
-
On March 13, 2009, Juan Mendez Sr. was admitted to a nursing facility. On that day, a doctor employed by the facility determined the father lacked the capacity to give informed consent or make...
-
Carter Enterprises can issue floating-rate debt at LIBOR +2 percent or fixed-rate debt at 10.00 percent. Brence Manufacturing can issue floating-rate debt at LIBOR +3.1 percent or fixed-rate debt at...
-
Briefly describe the two Oracle Administrative Tools and talk about some of their administration usage: -SQL*Plus - Oracle Enterprise Manager Database Express (EM Express) Question2: Explain briefly...
-
Name the following alcohols according to the IUPAC nomenclature system. Indicate stereochemistry (if any) and label the hydroxy groups as primary, secondary, or tertiary. OH Br OH (a) CH;CH,CHCH; (b)...
-
A firm is currently partially financed with zero-coupon debt that promises to repay bondholders $200 at maturity. These bonds mature one year from today at t-1. The firm is in a very risky industry,...
-
Maria, a single individual with wage income of $170,000 and no other income, is considering purchasing a new electric car. What are some of the features she should look for to be able to claim the...
-
A variable bit rate (VBR) AF flow contracts a committed information rate (CIR) of 1000 bytes/sec from a service provider and a peak information rate (PIR) of 10000 bytes/sec. For simplicity, assume...
-
A computer system has 8KB of main memory. Each word is 64 bits. The block size is 16 words. The computer has a fully associative cache of 128 blocks. What is the tag size? If a direct mapped cache is...
-
You have a 190-2 resistor and a 0.370-H inductor. Suppose you take the resistor and inductor and make a series circuit with a voltage source that has a voltage amplitude of 34.0 V and an angular...
-
What was Rita's total nonrefundable tax credits on her Delaware return? Explain
-
1. In the graph below, nurses and doctors are "inputs." The graph serves to illustrate the concepts of isocosts and isoquants. Curve R1 includes points A, B, and C. Curve R2 includes points A", B",...
-
What is the difference between direct materials and indirect materials?
-
Proof that for any group G, C(G) is characteristic, but not necessarily fully invariant.
-
Proof that If F is algebraically closed and tr.d.F/K is finite, then every K-monomorphism F F is in fact an automorphism.
-
Proof that If char K = p 0 and u K but a K p , then x -pn - a K[x] is irreducible for every n > 1.
-
Record the following details relating to a carpet retailer for the month of November 2017 and extract a trial balance as at 30 November 2017. 2017 Nov 1 Started in business with 15,000 in the bank. 3...
-
You are to enter up the necessary accounts for the month of October from the following information relating to a small printing firm. Then balance-off the accounts and extract a trial balance as at...
-
What would have been the balance on the account of C. De Freitas in MC17 on 19 May 2017? (A) A debit balance of 265 (B) A credit balance of 95 (C) A credit balance of 445 (D) A credit balance of 265
Study smarter with the SolutionInn App