A Adaptations of Algorithm 1 for different problems