Question
Hi, I am stuck with this problem. Please provide me a descriptive answer. Appreciate your help!! Consider the problem of determining the maximum in an
Hi, I am stuck with this problem. Please provide me a descriptive answer. Appreciate your help!!
Consider the problem of determining the maximum in an array S containing n real numbers.
Divide-and-conquer algorithm
a. Write the problem, inputs, outputs, and algorithm in pseudo-code.
b. Let T(n) denote the number of pair-wise comparisons of elements in S required by your algorithm. Write a recurrence relation for T(n) for your algorithm and solve it to determine T(n).
c. Draw a decision tree (comparison tree) for your algorithm when S is (a, b, c, d).
i) How many comparisons does your algorithm do in the best case?
ii) How many comparisons does your algorithm do in the worst case?
d. Is your algorithm optimal? Justify your answer.
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