this is the quick sort and I know that it has O(n^2) time complexity at worst case (when data is already sorted) put how I count the operation that makes this time complexity i.e which part of the code will mostly excute when elements are already sotrted so that when I count I end up with a function with O(n^2) time complexity
Help!
void quickSort( int A[], int left, int right )
{
if( left >= right )
return;
int P_ind = ( left + right )/2;
int pivot = A[P_ind];
swap( A[P_ind] , A );
int i = left;
int j = right - 1;
for(;;)
{
while( A[i] <= pivot && i < right )
i++;
while( A[j] > pivot && j > left )
j--;
if( i < j )
swap( A[i], A[j] );
else
break;
}
swap ( A[i], A right );
quickSort( A, left, i-1 );
quickSort( A, i+1, right );
}