\begin{algorithm} \caption{Single Array Allocate and Free Objects} \begin{algorithmic} \REQUIRE An array $A$ representing all doubly linked list nodes and variable $free$ indicating the head of free list \PROCEDURE{AllocateObject}{} \IF{$free == NIL$} \STATE \textbf{error} "out of space" \ELSE \STATE $x = free$ \STATE $free = A[x + 1]$ \COMMENT{ $A[x + 1]$ is conceptually $x.next$ } \RETURN x \ENDIF \ENDPROCEDURE \STATE \PROCEDURE{FreeObject}{$x$} \STATE $A[x + 1] = free$ \COMMENT{ $A[x + 1]$ is conceptually $x.next$ } \STATE $free = x$ \ENDPROCEDURE \end{algorithmic} \end{algorithm}