Jump to content

Ackermann Function


MauraF

Recommended Posts

Hello,

I'm new here and also new to Computer Sciences. I'm a first semester university student and so far we're only doing mathematics and a lot of theoretical background on computer sciences.

 

So in one of my assignments we have the option for 120 bonus points but it's pretty much exclusive to those who have programmed before and I find this quite unfair. We complained, so at least one of our tutors helped us in recommending some code snippets. But since I have never coded before I'm totally lost and I really would want to have at least a part of those bonus points.

 

The question is: 

"Calculate the Ackermann Function A for A(8,6). Write down all intermediate data."

 

Our tutor gave us this hint: I just have no idea what I should do with this? 

class Ackermann
{
  public static long ackermann( long n, long m )
  {
    if ( n == 0 )
      return m + 1;
    else
    
      if ( m == 0 )
        return ackermann( n - 1, 1 );
      else
        return ackermann( n - 1, ackermann(n, m - 1) );
    
  }
  public static void main( String args[] )
  {
    int x = 2,
        y = 2;
    System.out.println( "ackermann(" + x + "," + y + ")=" + ackermann(x,y) );
  }
}

One guy in another study group tried a c++ code, but I don't have the source and I wouldn't even have a clue how to use it... 

 

Help is really appreciated!

Link to comment
Share on other sites

1 hour ago, MauraF said:

Our tutor gave us this hint: I just have no idea what I should do with this? 

I would ignore most of it (creating a Class to calculate a single function: stupid overkill).

If you know nothing about programming, then you have quite a challenge. Start by finding some tutorials online to learn the basics. All you need to do is learn how to write a function (a "sub-program" that calculates a value for you) and print the result. I would choose a language like Python which is interactive and allows you to try things out quickly. You don't need to get to grips with compilers or any of that nonsense.

Once you are comfortable with the basics (write a program with a function to calculate the square of a number, for example) then you can translate the "ackerman" function from his example into Python (or whatever you choose to use).

 

Link to comment
Share on other sites

Hi all,

 

first I want to thank you for your help.

 

Unfortunately, I won't be able to learn any coding language within the time we have for the assignment. We got it on Monday and have to hand it in on Friday.

I would be glad to just get a small percentage of the bonus points, and I hope I can do that by calculating it by hand?

Link to comment
Share on other sites

5 minutes ago, MauraF said:

I hope I can do that by calculating it by hand?

That might be a challenge. You could try this: https://www.wolframalpha.com/input/?i=Ackerman(8,6)

See how many times you can click "More" in the expansion section ...

Just looking at the way the value of the function "explodes" for even small values of the first argument, this is not a trivial programming exercise. You would need to use a library that can handle arbitrarily large integers. And a very large amount of paper to print out the result!

https://en.wikipedia.org/wiki/Ackermann_function#Table_of_values

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.