Binary Tree - Method to recursively count the number of nodes on a level without a count parameter (Java)
问题 I'm looking to take some code I've written in Java for a binary tree class and remove the count parameter from the arguments, but keep the whole thing recursive. So, given a class with these variables: public class BinaryTree<E> { protected E data; protected BinaryTree<E> left,right; How could I do that for: public int levelCount(int count, int level){ if (data == null) {return 0;} if (count == level) {return 1;} else { return this.getRight().levelCount(count+1,level) + this.getLeft()