Professional Documents
Culture Documents
Metodos de Ordenamiento Java PDF
Metodos de Ordenamiento Java PDF
package javaapplication13;
/**
*
* @author users
*/
public class JavaApplication13 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int i;
int arr[] = { 5, 9, 3, 4, 1, 2, 27, 6, 18 };
System.out.println("\nHeap Sort\n---------------");
System.out.println("\nUnsorted Array\n---------------");
fnSortHeap(arr, i - 1);
System.out.println("\n\nSorted array\n---------------");
int i, o;
int lChild, rChild, mChild, root, temp;
root = (arr_ubound - 1) / 2;
for (o = root; o >= 0; o--) {
lChild = (2 * i) + 1;
rChild = (2 * i) + 2;
} else {
temp = array[i];
array[i] = array[mChild];
array[mChild] = temp;
}
}
}
temp = array[0];
array[0] = array[arr_ubound];
array[arr_ubound] = temp;
return;
}
}