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

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) {

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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Systems

ISBN: 9781284079630

5th Edition

Authors: J Stanley Warford

Question Posted: