Question

Write programs for the Ackerman function shown below in C and in Scheme (Racket). Functionality and...

Write programs for the Ackerman function shown below in C and in Scheme (Racket). Functionality and Documentation is critical in these programs. Be sure your code is your own. If you get outside help, you will receive a zero for this exam. When you submit the programs, upload the c code and scheme code in separate files. The Ackermann function is defined recursively for two non-negative integers’ s and t as follows. A(s, t) = {(t+1,@A(s-1,1),@A(s-1,A(s,t-1)),)┤ ■(if s=0@ if s>0 and t=0@ if s>0 and t>0) Follow the methods discussed for writing recursive methods. Implement the function A(s t) in C. The function should take two inter numbers, m and n, and return the value of A(s, t), which is a long integer. Notice that the Ackerman function is a very rapidly growing function. Even values of 4 for m and n will yield an extremely large number, and thus using a long integer as the return value is necessary. Write a main program that takes inputs of m and n from the keyboard; call the recursive function, and then print the results. Repeat the above coding exercise, but in Scheme.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The Code for given program is as follows:

#include <stdio.h>
int A(int,int );
int main()
{
int m,n;
scanf("%d%d",&m,&n);
int p= A(m,n);
printf("%d",p);
return 0;
}
int A(s,t)
{int t1;
if(s==0) { return (t+1);}
if(s>0 && t==0) { return A(s-1,t); }
if(s>0 && t>0) {t1 = A(s,t-1) ; return A(s-1, t1); }
}

Run Debug Stop Share H Save Beautify Language C main.c 1 #include <stdio.h> 2 int A(int,int); 3 int main() 4- 5 int min; 6 sc

-> on calling AC), D) ty= AC110) will be called → AC1,0) = AC00 condition of . So, 2 og > AC00) = return (t +)). .. Sreturn :

Add a comment
Know the answer?
Add Answer to:
Write programs for the Ackerman function shown below in C and in Scheme (Racket). Functionality and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs...

    PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs to:             -define a recursive procedure/function and call it.             -use syscall operations to display integers and strings on the console window             -use syscall operations to read integers from the keyboard. Assignment Description: Implement a MIPS assembly language program that defines "main", and "function1" procedures. The function1 is recursive and should be defined as: function1(n) = (2*n)+9                      if n <= 5              =...

  • I am looking for toe menu "3" Ackermann table lookup function. IN JAVA I already made...

    I am looking for toe menu "3" Ackermann table lookup function. IN JAVA I already made my own menu, value, trace functions I just need table lookup function Ackermann's function Please create the following menu for the Ackermann project. This program allows you to call the Ackermann function. Please choose a version of Ackermann's Function. 1) Ackermann value. 2) Ackermann trace 3) Ackermann table lookup. 4) Quit playing with the Ackermann Function. Please choose one of the 4 choices Ackermann's...

  • in large programs, it can be helpful to have a function specificaly for printing out an...

    in large programs, it can be helpful to have a function specificaly for printing out an error message to the user or to a log when an exception (an error) has occurred Generally speaking, errors are tracked through unique error codes, making it easy for the programmer to implement. Assume you are given the task to implement a function for manager wants you to implement a basic function for now to check the functionality Implement a function called displayError, with...

  • Scheme number computer a. Write a recursive procedure (digits n) that computes the number of digits...

    Scheme number computer a. Write a recursive procedure (digits n) that computes the number of digits in the integer n using a recursive process. For example, (digits 42) should return 2 and (digits 13579) should return 5. You may make use of the built in floor predicate for truncating decimals to whole numbers. b. Rewrite your procedure from part (a) using an iterative process. Call the function (digits-iter n).

  • Objective To program using the functional programming paradigm Assignment: Write the following functions using Scheme (or...

    Objective To program using the functional programming paradigm Assignment: Write the following functions using Scheme (or LISP if you prefer) . A function (binomial N k) that returns the binomial coefficients C(N, k), defined recursively as: C(NO) = 1, C(N, N) = 1, and, for 0<k < N E(N, k) = C(N-1, k) + C(N-1, k-1) 2. A function (mod N M) that returns the modulus remainder when dividing N by M 3. A function (binaryToDecimal b) that takes a...

  • Write a recursive scheme function EXP-DEPTH that returns the depth of the most nested parentheses in...

    Write a recursive scheme function EXP-DEPTH that returns the depth of the most nested parentheses in a list. (EXP-DEPTH ’A) is 0, (EXP-DEPTH ’( )) is 1, (EXP-DEPTH ’(1 2 3) ) should return 1. (EXP-DEPTH ’(I J ((K) L) M)) should return 3, since the element K is nested in three levels of parentheses. Please use scheme function

  • Below is is a scheme function. For your answer, write a comment for this piece of...

    Below is is a scheme function. For your answer, write a comment for this piece of code in valid scheme syntax. (define (factorial n) (if (=n0) (* n (factorial (- n 1))))) The elements to include in your comment that is described in your own w ords (succinctly, such as if you were commenting code instead of a survey) ... 1) the necessary formatting to indicate it is a legal scheme comment 2) expected input 3) expected output 4) what...

  • You must write each of the following scheme functions. You must use only basic scheme functions...

    You must write each of the following scheme functions. You must use only basic scheme functions do not use third-party libraries to support any of your work. Do not use any function with side effects. This problem need to use DrRacket software. Racket Language. Write a function named (first-n L1 N) that returns the first N elements of L1. If N is negative, return the empty list. If N exceeds the length of L1 return all elements of L1. (first-n...

  • Write a python program (recursive.py) that contains a main() function. The main() should test the following...

    Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...

  • 1. Recursion is ususally where a function calls itself; (another example of recursion is where function...

    1. Recursion is ususally where a function calls itself; (another example of recursion is where function A calls function B, and B calls C and C calls A, creating a loop in the calls). Some problems are most naturally solved recursively, such as writing the factorial function, or finding all the perumutations of a sequence, or checking if a string is a palindrome. Since those examples were done in class, here we will give you a toy example, which normally...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT