Galera não sei o que fiz de errado mas ele não compila em ordem... alguem pode me dar uma dica do que está errado???
vou postar o código abaixo...
public static void main(String[] args) {
int[] vetor = { 100, 15, 65, 65, 76, 3, 4, 6, 8, 89 };
int posOrdenada, i, pai, filho, t;
boolean continuarHeap;
posOrdenada = vetor.length;
i = vetor.length % 2;
do
if (i > 0){
i = i - 1;
t = vetor[ i ];
}
else{
posOrdenada = posOrdenada -1;
t = vetor[ posOrdenada ];
vetor[ posOrdenada ] = vetor[ 0 ];
pai = i;
filho = i*2 + 1;
continuarHeap = true;
while (filho > posOrdenada && continuarHeap)
if( (filho + 1 < posOrdenada) &&
(vetor[ filho + 1 ] > vetor[ filho ]) )
filho = filho + 1;
if(vetor[ filho ] > t){
vetor[ pai ] = vetor[ filho ];
pai = filho;
filho = pai * 2 + 1;
}
else
continuarHeap = false;
vetor[ pai ] = t;
}while(posOrdenada > 1);
for ( i = 0; i < vetor.length; i++) {
System.out.print(vetor[i] + ", ");
}
}
}