Ask Question

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)

+2
Answers (1)
  1. 14 November, 02:52
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers