← Questions
Top k with a deterministically noisy comparator
0
I was asked this
No reports yet. Sign in to say where you were asked it.
You must rank items through a comparison function cmp(a, b) that is wrong about 10% of the time, and consistently so: asking about the same pair again gives the same answer. Given n items and k, return the k largest.
- Say what guarantee you can offer, since repeated calls can't fix a wrong answer.
- Implement it, for example with a merge sort or tournament over the comparator, and measure how far the result is from the true order.
- Discuss making it more robust, such as counting wins over many pairwise comparisons, and what the extra comparisons cost.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
