Completed prototype algorithm for half alloc