The way I wrote my predicates, if there are more than two elements E it peels off from the first of the list to the first ocurrance of E. I have written the first rule for you assuming the member predicate is defined. I have defined the male predicate below. A. Name two methods for returning memory that is no longer in use back to the heap. Reference counts Mark and sweep B. Describe each of these methods in some detail.
Reference counts - each time a pointer points to a memory location increment the reference counter.
When the reference count is zero the memory is returned to the free memory list. Mark and sweep - set the mark to false, follow all pointers and set the mark to true for every memory location arrived at, finally return memory to free list if mark is false. C. Give relative advantages and disadvantages of each method. Reference counts - easier to implement and less time required to return memory to the free list. Disadvantage - pointers in a cycle will prevent the memory from being returned to the free list.