Question: Ackermanns 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 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 (1, 3) ackermann (0, 1) ackermann (2, 2)

ackermann (0, 0) ackermann (1, 3) ackermann (0, 1) ackermann (2, 2) ackermann (1, 1) ackermann (3, 2) ackermann (1, 2)

Step by Step Solution

3.35 Rating (170 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

A program that displays the return values of the follow... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Starting Out With Java From Control Structures Questions!