June 2017
Beginner
1296 pages
69h 23m
English
... pass of algorithm
23 }
24 }
25
26 // print a pass of the algorithm
27 public static void printPass(int[] data, int pass, int index) {
28 System.out.printf("after pass %2d: ", pass);
29
30 // output elements till swapped item
31 for (int i = 0; i < index; i++) {
32 System.out.printf("%d ", data[i]);
33 }
34
35 System.out.printf("%d* ", data[index]); // indicate swap
36
37 // finish outputting array
38 for (int i = index + 1; i < data.length; i++) {
39 System.out.printf("%d ", data[i]);
40 }
41
42 System.out.printf("%n "); // for alignment
43
44 // indicate amount of array that’s sorted
45 for (int i = 0; i <= pass; i++) {
46 System.out.print("-- ");
47 }
48 System.out.println();
49 }
50
51 public static void main(String[] args) {
52 SecureRandom ...Read now
Unlock full access