@Test public void shouldCalculatePathsToEveryLeaf() { BinaryNode<Integer> root = new BinaryNode<Integer>(1); BinaryNode<Integer> n2 = new BinaryNode<Integer>(2); BinaryNode<Integer> n3 = new BinaryNode<Integer>(3); BinaryNode<Integer> n4 = new BinaryNode<Integer>(4); BinaryNode<Integer> n5 = new BinaryNode<Integer>(5); root.setLeft(n2); root.setRight(n3); n3.setLeft(n4); n3.setRight(n5); List<List<BinaryNode>> paths = pathToEveryLeaf.calculate(root); assertEquals(3, paths.size()); assertPathTo(paths.get(0), root, n2); assertPathTo(paths.get(1), root, n3, n4); assertPathTo(paths.get(2), root, n3, n5); }
public List<List<BinaryNode>> calculate(BinaryNode<Integer> root) { if (root == null) { throw new IllegalArgumentException("You can't pass a null instance of BinaryNode"); } return calculatePathToLeafs(root, new LinkedList<BinaryNode>()); }
PathToEveryLeaf { public List<List<BinaryNode>> calculate(BinaryNode<Integer> root) { if (root == null) { throw new IllegalArgumentException("You can't pass a null instance of BinaryNode"); } return calculatePathToLeafs(root, new LinkedList<BinaryNode>()); } }
PathToEveryLeaf { public List<List<BinaryNode>> calculate(BinaryNode<Integer> root) { if (root == null) { throw new IllegalArgumentException("You can't pass a null instance of BinaryNode"); } return calculatePathToLeafs(root, new LinkedList<BinaryNode>()); }  }
PathToEveryLeaf { public List<List<BinaryNode>> calculate(BinaryNode<Integer> root) { if (root == null) { throw new IllegalArgumentException("You can't pass a null instance of BinaryNode"); } return calculatePathToLeafs(root, new LinkedList<BinaryNode>()); }  List<List<BinaryNode>> calculate(BinaryNode<Integer> root); }
PathToEveryLeaf { public List<List<BinaryNode>> calculate(BinaryNode<Integer> root) { if (root == null) { throw new IllegalArgumentException("You can't pass a null instance of BinaryNode"); } return calculatePathToLeafs(root, new LinkedList<BinaryNode>()); }  List<List<BinaryNode>> calculate(BinaryNode<Integer> root);  }