Posts

Showing posts with the label recurision

CS3401 Quiz 1 - No answers yet will update

Image
Question 1  (5 points)   How many times is the following factorial method invoked for complicatedSum(6)? public int complicatedSum(int n) {     if (n <= 3)         return n;     else if (n % 3 == 0)         return n * 3 + complicatedSum(n-1);     else if (n % 3 == 2)         return n * 2 + complicatedSum(n-1);     else         return n + complicatedSum(n-1); } Question 1 options: 6 5 4 3 Save Question 2  (5 points)   What does recursiveString("abcd") return if that method is defined by the following?   public String recursiveString(String str) {       if (str.length() < 2)       ...