Algorithms for hiring and outsourcing in the online labor market