Write the procedures ALLOCATE-OBJECT and FREE-OBJECT for a homogeneous collection of objects implemented by the single-array representation.
These procedures end up looking very similar to how they are written in the textbook, just with different syntax since we are dealing with a single array. Noting that we access the next value of the i-th object within \(A\) as \(A[i + 1]\), we have:
ALLOCATE-OBJECT()
1 if free == NIL
2 error "out of space"
3 else x = free
4 free = A[x + 1]
5 return x
FREE-OBJECT(x)
1 A[x + 1] = free
2 free = x