()
| 59 | |
| 60 | /* Create a tree that may or may not be a BST */ |
| 61 | public static TreeNode createTestTree() { |
| 62 | /* Create a random BST */ |
| 63 | TreeNode head = AssortedMethods.randomBST(10, -10, 10); |
| 64 | |
| 65 | /* Insert an element into the BST and potentially ruin the BST property */ |
| 66 | TreeNode node = head; |
| 67 | do { |
| 68 | int n = AssortedMethods.randomIntInRange(-10, 10); |
| 69 | int rand = AssortedMethods.randomIntInRange(0, 5); |
| 70 | if (rand == 0) { |
| 71 | node.data = n; |
| 72 | } else if (rand == 1) { |
| 73 | node = node.left; |
| 74 | } else if (rand == 2) { |
| 75 | node = node.right; |
| 76 | } else if (rand == 3 || rand == 4) { |
| 77 | break; |
| 78 | } |
| 79 | } while (node != null); |
| 80 | |
| 81 | return head; |
| 82 | } |
| 83 | |
| 84 | public static void main(String[] args) { |
| 85 | /* Simple test -- create one */ |
nothing calls this directly
no test coverage detected