I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.75
sub units 0.00
+
0

Smallest

Finds the smallest value of order k in the given array.
Controller: CodeCogs

Interface

C++

Smallest

 
template<class T> Tsmallestintn
T*data
intk )
This function uses the Hoare selection algorithm to return the k-th smallest value in a data set. If on input the order k is 1 the minimum entry is sought, while if k is equal to the size of the array, the maximum is calculated.

Example:

#include <codecogs/statistics/moments/smallest.h>
#include <iostream>
int main()
{
  int x[6] = {1, 5, 2, 3, 8, 7},
  small = Stats::Moments::smallest<int>(6, x, 4);
  std::cout << "The 4th smallest value of the array is: " << small;
  std::cout << std::endl;
  return 0;
}

Output:

The 4th smallest value of the array is: 5

References:

SUBSET, a library of C++ combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

Parameters

nthe size of the array
dataan array of numerical data for which you want to determine the k-th smallest value
kthe order of the largest value to return

Returns

the k-th smallest value in the given data set

Authors

Anca Filibiu (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.