Quick sort code:
void qsort(int l,int r) { int i,j; int t,x; i=l; j=r; x=A[(l+r)/2]; do{ while(A[i]<x) i++; while(A[j]>x) j--; if(i<=j) { t=A[i]; A[i]=A[j]; A[j]=t;i++;j--;} }while(i<=j); if(l<j) qsort(l,j); if(i<r) qsort(i,r); } Question: what is a pivot. Is it the same as the median?
How to find the median? pivot = a [(l + (rl) / 2)]; Is this also a median?
Why is the separating element sometimes chosen randomly, sometimes they take the median (which I don’t know how to find)?
Why sometimes after finding this middle element it turns out that the large middle elements are on the right and the smaller ones on the left? In general - confused. Wirth is incomprehensibly written.
Что такое медиана из трёх ключей ?