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 17:00
What allows you to create a wireless connection among your smart devices
Answers: 2
question
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Which best describes the role or restriction enzymes in the analysis of edna a. to break dna into fragments that vary in size so they can be sorted and analyzed b. to amplify small amounts of dna and generate large amounts of dna for analysis c. to purify samples of dna obtained from the environment so they can be analyzed d. to sort different sizes of dna fragments into a banding pattern that can be analyzed
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
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, 30.07.2021 22:40
question
Physics, 30.07.2021 22:40
Questions on the website: 13722360