Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (15) Given an array containing 9, 3, 5, 4, 10, 15, 8, 9, 8 provide the values returned from lines 8, 10g or 11

image text in transcribed

1. (15) Given an array containing 9, 3, 5, 4, 10, 15, 8, 9, 8 provide the values returned from lines 8, 10g or 11 in Find-Maximum-Subarray each time it is executed. The differences for this array are -6, 2, -1, 6, 5, -7, 1,-1 FIND-MAXIMUM-SUBARRAY(A, low, high) 1 if high == low 2 return (low, high, Allow // base case: only one element 3 else mid- L(low + high)/2 4(left-low, left-high, left-sum) - FIND-MAXIMUM-SUBARRAY (A, low,mid) FIND-MAXIMUM-SUBARRAY (A, mid + 1,high) FIND-MAX-CROSSING-SUBARRAY (A, low, mid, high) right-low, right-high.right-surn) = 6(cross-low, cross-high, cross-sum) 7 if left-sum right-sum and left-sum 2 cross-sum return (left-low, left-high. left-sum) 9elseif right-sum 2 left-sum and right-sum cross-sum return (right-low, right-high, right-sum) 11else return (cross-low, cross-high, cross-sum) 10 FIND-MAX-CROSSING-SUBARRAY . low, mid, high) 1 left-sum-oo sum = 0 3 for imid downto low 4 5 if sum>left-sum sum = sum + A [i] eft-sum-sum max-left = 1 8 right-sum-oo sum 0 10 for j mid 1 to high 12 13 if sum > right-sum right-sumsunm max-right- 15 return (max-left, max-right, left-sum +right-sum) 1. (15) Given an array containing 9, 3, 5, 4, 10, 15, 8, 9, 8 provide the values returned from lines 8, 10g or 11 in Find-Maximum-Subarray each time it is executed. The differences for this array are -6, 2, -1, 6, 5, -7, 1,-1 FIND-MAXIMUM-SUBARRAY(A, low, high) 1 if high == low 2 return (low, high, Allow // base case: only one element 3 else mid- L(low + high)/2 4(left-low, left-high, left-sum) - FIND-MAXIMUM-SUBARRAY (A, low,mid) FIND-MAXIMUM-SUBARRAY (A, mid + 1,high) FIND-MAX-CROSSING-SUBARRAY (A, low, mid, high) right-low, right-high.right-surn) = 6(cross-low, cross-high, cross-sum) 7 if left-sum right-sum and left-sum 2 cross-sum return (left-low, left-high. left-sum) 9elseif right-sum 2 left-sum and right-sum cross-sum return (right-low, right-high, right-sum) 11else return (cross-low, cross-high, cross-sum) 10 FIND-MAX-CROSSING-SUBARRAY . low, mid, high) 1 left-sum-oo sum = 0 3 for imid downto low 4 5 if sum>left-sum sum = sum + A [i] eft-sum-sum max-left = 1 8 right-sum-oo sum 0 10 for j mid 1 to high 12 13 if sum > right-sum right-sumsunm max-right- 15 return (max-left, max-right, left-sum +right-sum)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions

Question

How autonomous should the target be left after the merger deal?

Answered: 1 week ago