3 ms·
Many of O(n) algo for median have one compromise: They either return only the upper or lower median when n is even. In some applications, we might want average
by sytelus 12y ago
Many of O(n) algo for median have one compromise: They either return only the upper or lower median when n is even. In some applications, we might want average of these two instead. Are there any efficient algorithm there? Obviously it can be done with two calls to O(n) algo but can it be done more elegantly, efficiently and in single pass?