Skip to content

Instantly share code, notes, and snippets.

@Mario-SO
Last active April 27, 2020 18:00
Show Gist options
  • Select an option

  • Save Mario-SO/272e5901ca9022bfb39874ead26d1f6c to your computer and use it in GitHub Desktop.

Select an option

Save Mario-SO/272e5901ca9022bfb39874ead26d1f6c to your computer and use it in GitHub Desktop.
public ArrayList greedy(ArrayList candidates) {
solution;
while (!isSolution(solution) && (candidatesLeft(candidates)) {
cadidate = selectCandidate(candidates);
removeCandidate(candidate, candidates);
if (isGoodCandidate(candidate, solution)) {
addCandidate(candidate, solution);
}
}
if (isSolution(solution)) {
return solution;
} else {
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment