MauraF Posted December 5, 2017 Posted December 5, 2017 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! 1
studiot Posted December 5, 2017 Posted December 5, 2017 Do you know this website? Wolfram http://mathworld.wolfram.com/AckermannFunction.html By the way (BTW) since this is coursework we can't do it for you but we can hint and guide. However you must play your part and show some working. Also this should be in homework help.
Strange Posted December 5, 2017 Posted December 5, 2017 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).
studiot Posted December 5, 2017 Posted December 5, 2017 And use wolfram alpha to provide some known example results to test your program. 1
MauraF Posted December 6, 2017 Author Posted December 6, 2017 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?
Strange Posted December 6, 2017 Posted December 6, 2017 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
MauraF Posted December 6, 2017 Author Posted December 6, 2017 Yeah, it definitely is a nightmare task. We can't print out the result either, all must be handwritten. I think it's just to see who actually tries to do it. The more you do, the more points you get. :-/
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now