Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Recursion Intro Assignment. You may not use for or while. Any looping must be accomplished using recursion. You may not declare static or non-static member

Recursion Intro Assignment. You may not use for or while. Any looping must be accomplished using recursion. You may not declare static or non-static member fields only local or parameter variables allowed.

image text in transcribedimage text in transcribed

Consider an array of integers. You wish to find an approximate median. You have an idea: split the array into three pieces, find the approximate median of each piece, and then calculate the median of the three approximate medians (if you put the three approximate medians in sorted order, the one in the middle). There are a few details to consider. If we are trying to find the approximate median of one element, that element itself is its own median. If we are working with two elements, take the mean (average) which may be a fractional value. Otherwise, we are working with at least three elements. There are three possibilities for the number of elements: it is divisible by 3, it has a remainder of 1 when divided by 3, or a remainder of 2 when divided by 3. If the number of elements divided by 3 has a remainder of O: each piece should be n/3 elements. If a remainder of 1: the first piece should consist of the first In/3] elements, the last piece should consist of the last In elements, and the middle piece is the remaining rn/31 elements. In/31 rounds up. For example, if there were 4 elements, the first piece is the first element, the last piece is the last element, and the middle two elements constitute the middle piece.) If a remainder of 2: the first piece should consist of the first [n/31 elements, the last piece should consist of the last [n/31 elements, and the middle piece is the remaining In/3] elements. For example, if there were 8 elements, the first piece is the first 3 elements, the last piece is the last 3, and the middle two elements constitute the middle piece.)

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

5. Have you any experience with agile software development?

Answered: 1 week ago