1) Use the following input vector to find maximum sub vector. Step into the pseudocode on...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1) Use the following input vector to find maximum sub vector. Step into the pseudocode on slide 17 and 19 and show your stepping in neatly. At the least show the following, every step of recursion and following return values when returning from the recursions and find-max-crossing-subarray function. left-low, left-high, left-sum right-low, right-high, right-sum cross-low, cross-high, cross-sum 0 31 1 2 -41 59 3 26 4 -53 5 6 58 97 7 -93 8 -23 9 84 2) Mark in the given code the steps: Divide, Conquer, and Combine. 3) A problem similar to that of the maximum subvector is that of the maximum increasing subvector of a vector containing both positive and negative values. An increasing subvector is a slice of an array consisting of strictly increasing values. More precisely, such a subvector will begin at some index i, end at index j, and for any index k, i ≤ k < j, A[k] <A[k + 1]. Give the design of an algorithm following the divide-and-conquer paradigm that finds the maximum increasing subarray of some input array. FIND-MAXIMUM-SUBARRAY (A, low, high) if high == low return (low, high, A[low]) else mid= [(low + high)/2] (left-low, left-high, left-sum) = 1 2 3 4 5 6 7 8 9 10 11 FIND-MAXIMUM-SUBARRAY (A. low, mid) (right-low, right-high, right-sum) = FIND-MAXIMUM-SUBARRAY (A, mid+ 1, high) (cross-low, cross-high, cross-sum) = FIND-MAX-CROSSING-SUBARRAY (A, low, mid, high) 10 11 12 13 if left-sum right-sum and left-sum > cross-sum return (left-low, left-high, left-sum) elseif right-sum > left-sum and right-sum > cross-sum return (right-low, right-high, right-sum) else return (cross-low, cross-high, cross-sum) FIND-MAX-CROSSING-SUBARRAY (A, low, mid, high) left-sum∞0 1 2 sum = 0 3 for i 4 5 6 7 8 9 mid downto low sum + A[i] sum if sum left-sum //base case: only one element left-sum = sum max-lefi = i right-sum sum = 0 for j = mid + 1 to high sum sum + A[j] if sum > right-sum right-sum = sum max-right = j 14 15 return (max-left, max-right, left-sum + right-sum) 1) Use the following input vector to find maximum sub vector. Step into the pseudocode on slide 17 and 19 and show your stepping in neatly. At the least show the following, every step of recursion and following return values when returning from the recursions and find-max-crossing-subarray function. left-low, left-high, left-sum right-low, right-high, right-sum cross-low, cross-high, cross-sum 0 31 1 2 -41 59 3 26 4 -53 5 6 58 97 7 -93 8 -23 9 84 2) Mark in the given code the steps: Divide, Conquer, and Combine. 3) A problem similar to that of the maximum subvector is that of the maximum increasing subvector of a vector containing both positive and negative values. An increasing subvector is a slice of an array consisting of strictly increasing values. More precisely, such a subvector will begin at some index i, end at index j, and for any index k, i ≤ k < j, A[k] <A[k + 1]. Give the design of an algorithm following the divide-and-conquer paradigm that finds the maximum increasing subarray of some input array. FIND-MAXIMUM-SUBARRAY (A, low, high) if high == low return (low, high, A[low]) else mid= [(low + high)/2] (left-low, left-high, left-sum) = 1 2 3 4 5 6 7 8 9 10 11 FIND-MAXIMUM-SUBARRAY (A. low, mid) (right-low, right-high, right-sum) = FIND-MAXIMUM-SUBARRAY (A, mid+ 1, high) (cross-low, cross-high, cross-sum) = FIND-MAX-CROSSING-SUBARRAY (A, low, mid, high) 10 11 12 13 if left-sum right-sum and left-sum > cross-sum return (left-low, left-high, left-sum) elseif right-sum > left-sum and right-sum > cross-sum return (right-low, right-high, right-sum) else return (cross-low, cross-high, cross-sum) FIND-MAX-CROSSING-SUBARRAY (A, low, mid, high) left-sum∞0 1 2 sum = 0 3 for i 4 5 6 7 8 9 mid downto low sum + A[i] sum if sum left-sum //base case: only one element left-sum = sum max-lefi = i right-sum sum = 0 for j = mid + 1 to high sum sum + A[j] if sum > right-sum right-sum = sum max-right = j 14 15 return (max-left, max-right, left-sum + right-sum)
Expert Answer:
Answer rating: 100% (QA)
It seems youre asking to step through the divideandconquer algorithm for finding the maximum subarray of a given array based on the pseudocode provided in the images Lets go through the algorithm step ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
You invested in a bank certificate of deposit with an annual percentage rate of 8% and where the interest is paid quarterly. What is the effective annual rate at which you will earn every year from...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
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...
-
Which is not a difference between a limited liability company and a limited liability partnership? a. An LLC, unlike an LLP or LLLP, can exist with only one owner. b. All members of an LLC have...
-
Switch S has been closed for a long time, and the electric circuit shown in Figure P28.68 carries a constant current. Take C1 = 3.00 μF, C2 = 6.00 μF, R1 = 4.00 kΩ, and R2 = 7.00...
-
Name the zero vector for each of these vector spaces. (a) The space of degree three polynomials under the natural operations. (b) The space of 24 matrices. (c) The space {f: [0,,1] R | f is...
-
A hot, 0.5-m-diameter, 35 -mm-thick aluminum alloy disk is quenched from an initial temperature of \(T_{i}=\) \(400^{\circ} \mathrm{C}\) in a large oil bath of temperature \(T_{\infty}=35^{\circ}...
-
The following press release was issued by Haynes International: NEW YORK, March 19 (Reuters)Haynes International Inc., a producer of high-performance nickel and cobalt-based alloys, on Monday raised...
-
In-Class Exercise Altitude Temperature | Pressure H, ft T, F P, 20/14= -5000 74.84 1755 57.00 14.70 Troposphere Enter the data from this table. 5000 4617 12.23 10000 23.30 10.11 15000 6.55 8.30...
-
OMalley plc requires a bank loan for additional working capital to finance expansion. The bank has requested an audited income statement for the year 2022. The accountant for OMalley plc provides you...
-
Consider FED's problem that is described in the previous problem. To meet with state audit requirement, FED now has to ensure that it does not hold eggs for more than 20 days. 1. Does the current...
-
A plane wave propagates in free space (air) and has its electric field given by E =(-x+3y+0.52)e-05- 1. Determine the propagation vector . [3 marks] 2. Determine the polarization state of the plane...
-
Look for one famous CEO who implemented distinctive strategies that made their company successful. Research Format: I. Short Biography of the Strategist (The Strategist childhood, experiences, his...
-
Section A Preparing Statement of Changes in Equity and Statement of Cash Flows: The following are the financial statements of Small Limited for the year ended 30 September 2023: Statements of...
-
1. How would you use a market response model in the demand forecast? 2. Create and insert a demand forecast model (using actual or fictional data). To demonstrate effective analytical skills, explain...
-
Check weather the series convergent or divergent. (a) (1) (n + 1) n +1 n=2
-
14. How many integers between 1 and 1000 are not divisible by any of 2, 3, 11, 13?
-
On the basis of the details of the following fixed asset account, indicate the items to be reported on the statement of cashflows: ACCOUNT Land ACCOUNT NO. Balance Date Item Debit Credit Debit Credit...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-7. Ivan sold the following securities during the year and received a Form 1099-B that...
-
Amy is a calendar-year taxpayer reporting on the cash basis. Please indicate how she should treat the following items for 2012: a. She makes a deductible contribution to an IRA on April 15,...
-
John Williams (age 42) is a single taxpayer, and he lives at 1324 Forest Dr., Reno, NV 89501. His Social Security number is 555-94-9358. John's earnings and withholdings as the manager of a local...
-
In the second quarter of 2021, personal consumption expenditures, exports, and imports increased. Investment and government expenditure decreased. Real GDP increased by 6.5 percent following a 6.3...
-
When real GDP increased in the second quarter of 2021, consumption expenditure, exports, and imports increased. Fixed investment decreased, which included a decrease in business inventory investment....
-
Real exports of goods and services increased 6 percent in the second quarter of 2021, compared with a decrease of 2.9 percent in the first quarter of 2021. Real imports of goods and services...
Study smarter with the SolutionInn App