-2
How I calculate the running time of a recursive function?
public void ordenar(int vetor[],int i,int f){
boolean aux2=true;
int inicio=i,fim=f;
while(i<f){
if(vetor[i]>vetor[f]){
int aux=vetor[i];
vetor[i]=vetor[f];
vetor[f]=aux;
aux2=!aux2;
}
if(aux2)
f--;
else
i++;
}
for(int x=0;x<vetor.length;x++){
System.out.print(vetor[x]+" ");
}
if(i>inicio)
ordenar(vetor,inicio,i-1);
if(i<fim)
ordenar(vetor,i+1,fim);
}
For the record, use
System.currentTimeMillis
is not the best way to measure the running time/performance of something (read here to better understand). Prefer to use specialized tools - I usually use the JMH, but the link already indicated has other options– hkotsubo