Optimization strategies with resource scarcity: From immunization of networks to the traveling salesman problem