MCPcopy Create free account
hub / github.com/careercup/ctci / randomBST

Method randomBST

java/CtCILibrary/CtCILibrary/AssortedMethods.java:171–178  ·  view source on GitHub ↗
(int N, int min, int max)

Source from the content-addressed store, hash-verified

169 }
170
171 public static TreeNode randomBST(int N, int min, int max) {
172 int d = randomIntInRange(min, max);
173 TreeNode root = new TreeNode(d);
174 for (int i = 1; i < N; i++) {
175 root.insertInOrder(randomIntInRange(min, max));
176 }
177 return root;
178 }
179
180 /* Creates tree by mapping the array left to right, top to bottom. */
181 public static TreeNode createTreeFromArray(int[] array) {

Callers 1

createTestTreeMethod · 0.95

Calls 2

randomIntInRangeMethod · 0.95
insertInOrderMethod · 0.95

Tested by

no test coverage detected