Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. (15) Given the following C program: int result; int f(int n) { int y1, y2; if (n == 1) return 2; else if
1. (15) Given the following C program: int result; int f(int n) { int y1, y2; if (n == 1) return 2; else if (n == 2) return 1; else if (n > 2) { y1 = f(n - 1); //ra2 y2 = f(n 2); //ra3 return 2 y1 - y2; } } int main() { result = f(5); //ral printf("%d ", result); return 0; } a) Draw the call tree of the program and find the output. Label the return value on each edge of the tree. b) Draw the image of the run time stack just before (5) is returned. (You need fill in all the boxes of the run time stack with proper info.) c) Based on the run time stack, determine the stack related addresses of the following: yl: .equate y2: .equate n: .equate Writing requirements on your paper: For problem a, draw the call tree following its requirements. For problem b, draw the run time stack following its requirements. For problem c, copy the subquestions in the same layout and then fill the blanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started