Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tukey's ninthers def tukeys_ninthers (items ) : Back in the day when computers were much slower and had a lot less RAM for our programs

image text in transcribed
Tukey's ninthers def tukeys_ninthers (items ) : Back in the day when computers were much slower and had a lot less RAM for our programs to work in, special techniques were necessary to achieve things that we can now do with easy couple of lines of code. In this spirit, Tukey's Ninthers is a clever approximation algorithm from the seventies to quickly find the median element of an unsorted list, or at least find some element that is close to the true median with high probability. In this problem, the median element of the list is defined to be the element that would end up in the middle position, were that list actually sorted. The algorithm itself is very simple. Conceptually split the list into sublists of three elements each, and use an if-else ladder of ordinary comparisons to find the median element for each these sublists. Collect these medians of three into a new list (that therefore has one third of the length of the original list), and keep doing the same until only one element remains. (For simplicity, your function can assume that the length of items is always some power of three.) In the following

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

Prove that (R 2 , U) is second countable.

Answered: 1 week ago

Question

What is population?

Answered: 1 week ago

Question

Explain the study in demography?

Answered: 1 week ago

Question

Define social demography?

Answered: 1 week ago