public void completeToLevel(int level) { // Added in exception check since we didn't get to that if (level < 1) { throw new IllegalArgumentException(); } overallRoot = completeToLevel(overallRoot, 1, level); } private IntTreeNode completeToLevel(IntTreeNode root, int curr, int level) { if (curr <= level) { if (root == null) { root = new IntTreeNode(-1); } root.left = completeToLevel(root.left, curr + 1, level); root.right = completeToLevel(root.right, curr + 1, level); } return root; } /* This is the incorrect version I wrote during the A lecture. * If we had time in lecture to **Verify** our solution, we would have caught it and fixed it * like we should on the final exam. It's a good exercise to figure out WHY this doesn't work in * all cases. This is why verifying is important! private IntTreeNode completeToLevel(IntTreeNode root, int curr, int level) { if (root == null) { if (curr <= level) { root = new IntTreeNode(-1); } } else { root.left = completeToLevel(root.left, curr + 1, level); root.right = completeToLevel(root.right, curr + 1, level); } return root; } */