xxxxxxxxxx141/** Return the max value in A[start..end] */2public int findMax(int[] a, int start, int end) {3 currentMax = a[start]4 for i in start+1..end:5 if a[i] is bigger, update currentMax6 return currentMax;7}89/** Print the min of several subarrays of A10 * Precondition: A.length >= 50. */11public static void mins(A) {12 for i in 0..50:13 print(findMin(A, 0, i));14}xxxxxxxxxx1public int f(int n) {2 while (n > 0) {3 System.out.println(n);4 n = n/2;5 }6}merge methodxxxxxxxxxx131merge(A, start, end):2 initialize i, j3 B = deep copy of A4 while neither uncopied segment is empty:5 copy the smaller of B[i], B[j]6 into A[k]7 increment i or j8 increment k9 while one uncopied segment is empty:10 copy the next element in the nonempty 11 segment into A[k]12 increment i or j13 increment kpartition methodxxxxxxxxxx91partition(A, start, end):2 initialize i, j3 while i < j:4 if A[i] <= p:5 swap(A, i, i-1)6 i++7 else:8 swap(A, i, j-1)9 j--x
1LSDRadixSort(A):2 create one bucket (queue) for each digit (0 to 9)3 for each digit (least- to most-significant):4 for v in A:5 put v into the bucket based on digit6 for each bucket, starting from smallest digit7 while bucket is not empty:8 move element to the next position in the array