subject

Design a recursive algorithm called Extrema(A, p,r) that, given an array A[1...n] finds and returns both the min and max of the subarray Aſp...r] as an ordered pair: (min(Ap...r]), max(Aſp...r])). Your algorithm should perform exactly [3n/2] – 2 array comparisons on an input array of length n. (Hint: Section 9.1 of the text describes an iterative algorithm that does this.) a. Write your algorithm in pseudo-code. b. Prove the correctness of your algorithm by induction on m = r - p + 1, the length of the subarray Aſp - r]. c. Write a recurrence for the number of comparisons performed on A[1...n], and show that T(n) = [3n/2] – 2 is its solution.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:30
At an open or uncontrolled intersection, yield if a. your road is paved and the crossroad is not b. the cross road is paved and yours is not c. you have two or more passengers in your vehicle d. you did not yield in the last intersection
Answers: 1
question
Computers and Technology, 22.06.2019 11:00
Which are examples of note-taking tools? check all that recording devices sticky notes digital highlighters paper flags highlighting pens digital displays digital flags
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
question
Computers and Technology, 24.06.2019 21:30
What need most led to the creation of the advanced research projects agency network? darpa wanted scientists to be able to collaborate and share research easily. darpa wanted american and russian politicians to be able to communicate. darpa wanted astronauts to be able to contact nasa and the white house. darpa wanted factory owners to be able to coordinate supply chains.
Answers: 1
You know the right answer?
Design a recursive algorithm called Extrema(A, p,r) that, given an array A[1...n] finds and returns...
Questions
question
Mathematics, 06.12.2019 11:31
question
Mathematics, 06.12.2019 11:31
Questions on the website: 13722363