Arrays 将代码写入伪代码

Arrays 将代码写入伪代码,arrays,sorting,quicksort,swap,pseudocode,Arrays,Sorting,Quicksort,Swap,Pseudocode,我需要帮助将此代码写入伪代码 public void quickSort(int[] A, int p, int r) { if (p < r) { int q = partition(A, p, r); quickSort(A, p, q); quickSort(A, q + 1, r); } } private int partition(int[] A, int p, int r) { int x = A[p]

我需要帮助将此代码写入伪代码

public void quickSort(int[] A, int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q);
        quickSort(A, q + 1, r);
    }
}

private int partition(int[] A, int p, int r) {
    int x = A[p]; // pivot element x
    int i = p - 1;
    int j = r + 1;

    // partition
    while (true) {
        do {
            j--;
        } while (A[j] > x);
        do {
            i++;
        } while (A[i] < x);

        if (i < j)
            swap(A, i, j);
        else
            return j;
    }
}

    private void swap(int[] A, int i, int j) {
    int tmp = A[i];
    A[i] = A[j];
    A[j] = tmp;
public void快速排序(int[]A,int-p,int-r){
if(px);
做{
i++;
}而(A[i]
} }

用于每个(未排序的)分区
将第一个元素设置为轴
storeIndex=pivotIndex+1
对于i=pivotIndex+1到rightmostIndex
如果元素[i]<元素[pivot]
交换(i,存储索引);存储索引++
交换(pivot,storeIndex-1)
for each (unsorted) partition
  set first element as pivot
  storeIndex = pivotIndex + 1
  for i = pivotIndex + 1 to rightmostIndex
    if element[i] < element[pivot]
      swap(i, storeIndex); storeIndex++
  swap(pivot, storeIndex - 1)