MCPcopy
hub / github.com/careercup/ctci / main

Method main

java/Chapter 18/Question18_6/QuestionC.java:112–130  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

110
111
112 public static void main(String[] args) {
113 int numberOfTests = 1000;
114 int count = 0;
115 while (count < numberOfTests) {
116 int[] array = AssortedMethods.randomArray(10, -1000, 1000);
117 if (isUnique(array)) {
118 int n = AssortedMethods.randomIntInRange(0, array.length - 1);
119 int rank1 = rank(array.clone(), 0, array.length - 1, n);
120 int rank2 = rankB(array.clone(), n);
121
122 if (rank1 != rank2) {
123 System.out.println("ERROR: " + rank1 + " " + rank2);
124 AssortedMethods.printIntArray(array);
125 }
126 count++;
127 }
128 }
129 System.out.println("Completed " + count + " runs.");
130 }
131
132}

Callers

nothing calls this directly

Calls 7

randomArrayMethod · 0.95
isUniqueMethod · 0.95
randomIntInRangeMethod · 0.95
rankMethod · 0.95
rankBMethod · 0.95
printIntArrayMethod · 0.95
cloneMethod · 0.45

Tested by

no test coverage detected