Algorithm 1 Single Array Allocate and Free Objects

Require: An array AA representing all doubly linked list nodes and variable freefree indicating the head of free list

1:procedure AllocateObject()

2:if free==NILfree == NIL then

3:error "out of space"

4:else

5:x=freex = free

6:free=A[x+1]free = A[x + 1] // A[x+1]A[x + 1] is conceptually x.nextx.next

7:return x

8:end if

9:end procedure

10:

11:procedure FreeObject(xx)

12:A[x+1]=freeA[x + 1] = free // A[x+1]A[x + 1] is conceptually x.nextx.next

13:free=xfree = x

14:end procedure