nth-element

algorithm for nth_element

I have recently found out that there exists a method called nth_element in the STL. To quote the description: Nth_element is similar to partial_sort, in that it partially orders a range of elements: it arranges the range [first, last) such that the element pointed to by the iterator nth is the same as the element that wou...

Does C# have a std::nth_element equivalent?

I'm porting some C++ code to C#. Does C# have an equivalent to std::nth_element() or do I need to roll my own? ...

Medians of upper and lower halves of a vector

I am trying to compile an Octave .oct function to calculate the medians of the upper and lower "halves" of a sorted vector which will vary in length e.g. for an odd length vector such as [5,8,4,6,7] I want the "lower" median value of 4,5 and 6 and the "upper" median value of 6,7 and 8 (6 is part of both calculations), and for an even len...