I'm having a problem here in this code. These are functions for an array of objects using the quick sort algorithm, and I'm having the Stackoverflow error, and I can not identify the source. Someone help me to identify the source of the error?
static Musica[] ordenarMusicosIdQuickSort(Musica[] musica){
return ordenarMusicosIDQuickSort(musica, 0, musica.length);
}
static Musica[] ordenarMusicosIDQuickSort(Musica[] musica, int left, int right){
if(left<right){
int posicaoPivot = partition(musica, left, right-1);
musica = ordenarMusicosIDQuickSort(musica, left, right);
musica = ordenarMusicosIDQuickSort(musica, posicaoPivot + 1, right);
}
return musica;
}
static int partitionID(Musica[] musica, int left, int right){
Musica pivot=musica[right];
int startR=left-1;
for(int endR=left; endR<right; endR++){
if(musica[endR].id_interprete>pivot.id_interprete){
startR++;
Musica temp=musica[endR];
musica[endR]=musica[startR];
musica[startR]=temp;
}
}
Musica temp=musica[right];
musica[right]=musica[startR+1];
musica[startR+1]=temp;
return startR+1;
}
}