Question
Assume that we have a special computer that can find the maximum of several values at a time. On the tth comparison step it can
Assume that we have a special computer that can find the maximum of several values at a time. On the tth comparison step it can find the maximum of f (t) numbers in an array. The format of the operation (executed on the tth comparison step) is k max index(A,i,j) where j i+ 1 f (t). It assigns to k the index of a maximum value from A[i], A[i+ 1], . . . , A[j]. (a) Give an efficient algorithm to find the maximum of n numbers where f (t) = t + 1. Write the pseudo-code. Try to minimize the number of comparison steps. Exactly how many comparison steps does your algorithm use? (b) Give an efficient algorithm to find the maximum of n numbers where f (t) = 2t1 + 1. Write the pseudo-code. Try to minimize the number of comparison steps. Exactly how many comparison steps does your algorithm use?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started