Selection sort

Write a procedure

        void (vector<double>& v, int m);

that recursively sorts @v[0..m]@ in non-decreasing order using the
selection sort algorithm. The rest of @v@ must not be modified.

Interface

+-------:+:---------------------------------------------------------+
| C++    |     void selection_sort(vector<double>& v, int m);       |
+--------+----------------------------------------------------------+
| C      |     void selection_sort(double v[], int m);              |
+--------+----------------------------------------------------------+
| Java   |     public static void selectionSort(double[] v, int m); |
+--------+----------------------------------------------------------+
| Python |     selection_sort(v, m)  # returns None                 |
+--------+----------------------------------------------------------+
|        |     selection_sort(v: list, m: int) -> None              |
+--------+----------------------------------------------------------+

Precondition

−1≤ @m@ < @v.size()@.

Observation

The function @position_maximum()@ of the
exercise problem://problemsjutge.org:problems/p1/roura/posicio-maxim.pbm
should be useful.

Observation

You only need to submit the required procedure; your main program will
be ignored.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:54:28.909Z

© Jutge.org, 2006–2026.
https://jutge.org
