1
It’s part of an sorting algorithm, reading the code made it seem to me that the function never makes the call: sort(mid+1, high)
; gets into loop at first sort(low, mid)
; until you leave the if
, and that return
I also don’t understand what it’s for.
void sort(int low, int high) {
int mid;
if(low < high) {
mid = (low + high) / 2;
sort(low, mid);
sort(mid+1, high);
merging(low, mid, high);
} else {
return;
}
}
Explain further your doubt
– Luiz Augusto
it would be good if you hit the indentation of the code to facilitate the understanding of the same...put 4 spaces at the beginning of each line
– zentrunix
Here you can find the explanation of this sorting method: https://pt.wikipedia.org/wiki/Merge_sort or your question is about the functioning of recursive functions?
– anonimo
It is part of an sorting algorithm, reading the code seemed to me that the function never makes the call: Sort(mid+1, high); it loops in the first Sort(low, mid); until it leaves the if, and this Return also did not understand what it is for.
– Vitor
It is the merge Sort implementation algorithm.
– user142154
@Vitor Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero