the file Ackermann.cpp. Inside the file the recursive Ackermann function is implemented (described in Chapter 14 Programming Challenge 9). Do the following and answer the three questions: a) Run the program. What happens? b) Now uncomment the code that is commented out and run the program again. What happens now? c) What do you think is going on?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Download the file Ackermann.cpp. Inside the file the recursive Ackermann function is implemented (described in Chapter 14 Programming Challenge 9). Do the following and answer the three questions:
a) Run the program. What happens?
b) Now uncomment the code that is commented out and run the program again. What happens now?
c) What do you think is going on?
11
#include <iostream>
12
using namespace std;
13
//Function Prototype
long ack(long m, long n);
14
15
16
17
int main( )
18 E {
for (int m = 0; m <=1; m++)
for (int n = 0; n <=1; n++)
cout <« "A(" «m <« "," <« n « ") is
19
20
21
« ack(m, n) <« endl;
22
// On Most computers the following code
// will cause a runtime error.
// Uncomment the code and see what happens.
// what do you think is going on?
23
24
25
26
27
for (int m = 1; m <= 3; m ++)
cout « "A(" « m <« "," <« 2 « ") is " « ack(m, 2)
<« endl;
28
29
30
31
*/
32
33
return e;
}
35
34
//******
//
//****
36
******
37
Ackerman
*
38
******
39
long ack(long m, long n)
40 E {
if (m
return n + 1;
if (n
return ack (m -1, 1);
else
return ack(m-1, ack(m-1, ack(m, n-1)));
}
41
e)
42
43
e)
==
44
45
46
47
Transcribed Image Text:11 #include <iostream> 12 using namespace std; 13 //Function Prototype long ack(long m, long n); 14 15 16 17 int main( ) 18 E { for (int m = 0; m <=1; m++) for (int n = 0; n <=1; n++) cout <« "A(" «m <« "," <« n « ") is 19 20 21 « ack(m, n) <« endl; 22 // On Most computers the following code // will cause a runtime error. // Uncomment the code and see what happens. // what do you think is going on? 23 24 25 26 27 for (int m = 1; m <= 3; m ++) cout « "A(" « m <« "," <« 2 « ") is " « ack(m, 2) <« endl; 28 29 30 31 */ 32 33 return e; } 35 34 //****** // //**** 36 ****** 37 Ackerman * 38 ****** 39 long ack(long m, long n) 40 E { if (m return n + 1; if (n return ack (m -1, 1); else return ack(m-1, ack(m-1, ack(m, n-1))); } 41 e) 42 43 e) == 44 45 46 47
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education