Question: 23. The recursive binomial coefficient function in Figure 6.25 can be simplified by omitting y1 and y2 as follows: int binCoeff(int n, int k) {

23. The recursive binomial coefficient function in Figure 6.25 can be simplified by omitting y1 and y2 as follows:

int binCoeff(int n, int k) {

if ((k == 0) || (n == k)) {

return 1;

}

else {

return binCoeff(n - 1, k) + binCoeff(n - 1, k - 1);

}

}

Write a Pep/9 assembly language program that calls this function. Keep the value returned from the binCoeff(n - 1, k) call on the stack, and push the actual parameters for the call to binCoeff(n - 1, k - 1) on top of it. FIGURE 6.50 shows a trace of the run-time stack where the stack frame contains four words (for retVal, n, k, and retAddr) and the shaded word is the value returned by a function call. The trace is for a call of binCoeff(3, 1) from the main program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Principles Algorithms And Systems Questions!