Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Decrease - and - Conquer Algorithm - Maximum Element in Array a ) Write a recursive decrease - and - conquer algorithm to calculate the

Decrease-and-Conquer Algorithm - Maximum Element in Array
a) Write a recursive decrease-and-conquer algorithm to calculate the maximum element in a nonempty array of real numbers. Your algorithm should work by comparing the last element in the array with the maximum of the "remaining front end" of the array.
For example, to find the largest element in the array (:5,13,9,10:) your algorithm should call itself to find the maximum of (:5,13,9:) and return either 10 or the result of the recursive call, whichever is larger.
Do not use Python's built-in max() function.
Do not rearrange the elements of the array by sorting or partially sorting them.
Do not use any loops.
You can assume that the array has at least one element in it.
Your function call should should be
Maximum(A, right)
where the two input parameters are the array and right index. With these input parameters, the function should return the maximum array element from A[0] to A[right]. Return the value of the array element, not the index where it occurs in the array.
b) Trace your algorithm with
A=17,62,49,73,26,51>
c) Write a recurrence relation for the number of comparisons of array elements that are performed for a problem of size n. Then perform asymptotic analysis to determine the Big-Oh class for this algorithm
image text in transcribed

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions