Fastest code C/C++ to select the median in a set of 27 floating point values

后端 未结 15 1192
梦谈多话
梦谈多话 2020-12-07 09:24

This is the well know select algorithm. see http://en.wikipedia.org/wiki/Selection_algorithm.

I need it to find the median value of a set of 3x3x3 voxel values. Sinc

15条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 09:52

    When having let's say a million different values from which you need the median. Is it possible to base your median on a subset of those million, let's say 10%. So that the median is close to the n-th element which divides the values in 2 equal (or almost equal) subsets? Therefor, for finding the median you'll need less than O(n)-times (in this case O(1/10n) and hereby come closer to optimal sorting with quicksort in O(nlogn)?

提交回复
热议问题