Selection sort P81602


Statement
 

pdf   zip   main.cc   main.c   main.java   main.py

thehtml

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 ‍ should be useful.

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

Information
Author
Salvador Roura
Language
English
Translator
Carlos Molina
Original language
Catalan
Other languages
Catalan
Official solutions
C C++ Java Python
User solutions
C++ Java Python