A "tracing tree" shows the order of the execution for the chain of function calls, to help us better understand how the output is generated and what the memory looks like for each function call. When function A calls function B, the name of function B should be written underneath A, with an indentation. We use an arrow to show A called B (see the blue arrow below). The return value is also shown next to the arrow that follows the name of the function (see the red arrows below) A(A's actual parameters) return value of function A B(B's actual parameters) We can use the tracing tree to get an understanding of how a recursion works. In this activity, suppose we call the given method with (input, 0, 4), where input is an integer array containing {1, 2, 3, 4, 5}. Fill in the gaps in the tracing tree that shows the correct order of function call in this recursion. public static int func1(int[] input, int s, int e) { if (s e) return input[s]; return func1(input, s, (s+e)/2) + func1(input, (s+e)/2+1, e); } else { } return value of function B == ?

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
icon
Concept explainers
Question
A "tracing tree" shows the order of the execution for the chain of function calls, to help us better
understand how the output is generated and what the memory looks like for each function call. When
function A calls function B, the name of function B should be written underneath A, with an
indentation. We use an arrow to show A called B (see the blue arrow below). The return value is also
shown next to the arrow that follows the name of the function (see the red arrows below)
A(A's actual parameters)
return value of function A
B(B's actual parameters)
We can use the tracing tree to get an understanding of how a recursion works.
In this activity, suppose we call the given method with (input, 0, 4), where input is an integer array
containing {1, 2, 3, 4, 5}. Fill in the gaps in the tracing tree that shows the correct order of function
call in this recursion.
public static int func1(int[] input, int s, int e) {
if (s
e)
return input[s];
return func1(input, s, (s+e)/2) + func1(input, (s+e)/2+1, e);
}
else {
return value of function B
}
==
Transcribed Image Text:A "tracing tree" shows the order of the execution for the chain of function calls, to help us better understand how the output is generated and what the memory looks like for each function call. When function A calls function B, the name of function B should be written underneath A, with an indentation. We use an arrow to show A called B (see the blue arrow below). The return value is also shown next to the arrow that follows the name of the function (see the red arrows below) A(A's actual parameters) return value of function A B(B's actual parameters) We can use the tracing tree to get an understanding of how a recursion works. In this activity, suppose we call the given method with (input, 0, 4), where input is an integer array containing {1, 2, 3, 4, 5}. Fill in the gaps in the tracing tree that shows the correct order of function call in this recursion. public static int func1(int[] input, int s, int e) { if (s e) return input[s]; return func1(input, s, (s+e)/2) + func1(input, (s+e)/2+1, e); } else { return value of function B } ==
Func1(
input, 2, 2
input, 4, 4
1
4
)
Func1(
➜Func1(
input, 0, 1
3
Func1(
Func1(
Func1(
Func1(
6
)
input, 0, 0
Func1(
Func1(
:)
:)
input, 3, 4
input, 1, 1
input, 0, 4
)
input, 3, 3,
9
5
input, 0, 2
15
2
Transcribed Image Text:Func1( input, 2, 2 input, 4, 4 1 4 ) Func1( ➜Func1( input, 0, 1 3 Func1( Func1( Func1( Func1( 6 ) input, 0, 0 Func1( Func1( :) :) input, 3, 4 input, 1, 1 input, 0, 4 ) input, 3, 3, 9 5 input, 0, 2 15 2
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Depth First Search
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
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