diff --git a/src/com/interview/dynamic/CountNumberOfTreesInBST.java b/src/com/interview/dynamic/CountNumberOfTreesInBST.java index a397b244..7bd39d87 100644 --- a/src/com/interview/dynamic/CountNumberOfTreesInBST.java +++ b/src/com/interview/dynamic/CountNumberOfTreesInBST.java @@ -10,16 +10,15 @@ int countTreesRec(int numKeys) { if (numKeys <=1) { return(1); } - else { - int sum = 0; - int left, right, root; - for (root=1; root<=numKeys; root++) { - left = countTreesRec(root - 1); - right = countTreesRec(numKeys - root); - sum += left*right; - } - return(sum); + + int sum = 0; + int left, right, root; + for (root=1; root<=numKeys; root++) { + left = countTreesRec(root - 1); + right = countTreesRec(numKeys - root); + sum += left*right; } + return(sum); } public int countTrees(int n){