Implemented Cheney's compacting algorithm