Skip to content

Instantly share code, notes, and snippets.

@cristianmiranda
Created September 20, 2015 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianmiranda/4a7d60264c6711ea1e94 to your computer and use it in GitHub Desktop.
Save cristianmiranda/4a7d60264c6711ea1e94 to your computer and use it in GitHub Desktop.
Seleccion.java
package edu.unlam.impl;
import edu.unlam.Ordenadora;
public class Seleccion extends Ordenadora {
@Override
public void sort(Comparable[] elements) {
int n = elements.length;
for (int i = 0; i < n; i++) {
int min = i;
for (int j = i+1; j < n; j++) {
if (less(elements[j], elements[min])) min = j;
}
exch(elements, i, min);
assert isSorted(elements, 0, i);
}
assert isSorted(elements);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment