Created
September 20, 2015 22:25
-
-
Save cristianmiranda/4a7d60264c6711ea1e94 to your computer and use it in GitHub Desktop.
Seleccion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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