Implements greedy heuristic 1