Ask Question
8 April, 12:14

Complete the following Programming Assignment using Recursion. Use good programming style and all the concepts previously covered. Submit the. java files electronically through Canvas by the above due date (In a zip file). This also includes: Requirements (for this problem), Pseudo-Code, UML, Java Doc (s) and an explanation, etc., which must be in the correct format. 9. Ackermann's Function Ackermann's function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Write a method ackermann (m, n), which solves Ackermann's function. Use the following logic in your method: If m=0 then return n + 1 If n = 0 then return ackermann (m - 1, 1) Otherwise, return ackermann (m - 1, ackermann (m, n - 1)) Test your method in a program that displays the return values of the following method calls: ackermann (0, 0) ackermann (0, 1) ackermann (1, 1) ackermann (1, 2) ackermann (1, 3) ackermann (2, 2) ackermann (3, 2)

+3
Answers (1)
  1. 8 April, 15:51
    0
    public class Ackermann {

    public static int ackermann's (int m, int n) {

    if (m = = 0) {

    return n + 1;

    } else if (n = = 0) {

    return ackermann's (m-1, 1);

    } else {

    return ackermann (m - 1, ackermann (m, n - 1));

    }

    }

    public static void main (String[] args) {

    System. out. println (ackermann (0, 0));

    System. out. println (ackermann (0, 1));

    System. out. println (ackermann (1, 1));

    System. out. println (ackermann (1, 2));

    System. out. println (ackermann (1, 3));

    System. out. println (ackermann (2, 2));

    System. out. println (ackermann (3, 2));

    }

    }

    1

    2

    3

    4

    5

    6

    7

    29

    Process finished with exit code 0
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Complete the following Programming Assignment using Recursion. Use good programming style and all the concepts previously covered. Submit ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers