Algorithm templates