Template Function otyca::median

Function Documentation

template<typename T>
T otyca::median(const std::vector<T> &v)

Calculates the median of a vector.

This function calculates the median of a vector by first sorting the vector and then returning the middle element. If the size of the vector is even, it returns the lower middle element.

Template Parameters:

T – The type of the elements in the vector (e.g., int, float).

Parameters:

v – The input vector from which the median will be calculated.

Returns:

The median element of the vector.