# Assignment 11 Solutions

1. Do problem 6, from chapter 14 of the notes.

6. Figure 14.6 illustrates only one example of the initial layout of free blocks using the binary buddy system in a memory region that does not start at location zero or has a size that is not a power of two. For an arbitrary block of size n, where n is an arbitrary integer, what is the largest size of free block that is guaranteed to be available?

First find i such that 2i < n < 2i+1. It may be possible to find a block of size 2i, but you are guaranteed to be able to find a block of size 2i-1.

2. Consider this little bit of code:
```   int fibonacci(int i);
{
int f1,f2;
if (i < 2) return i;
f1 = fibonacci(i-1);
f2 = fibonacci(i-2);
return f1 + f2;
}
```

Describe the contents and structure of the activation record for fibonacci() taking into account everything you know about assembly language programming. State any assumptions you made; for example, you will get a different result if you assume f1 and f2 are stored in RAM or are temporarily assigned to registers.

Here, we assume everything is in RAM to avoid questions about registers, except that we assume the return value is passed in a register.