Question: 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
Get step-by-step solutions from verified subject matter experts
