Python Quest

Track 16 · Lesson 9 of 12

Greedy algorithms

Build a solution one locally best choice at a time — making change, scheduling bookings, packing tasks — and learn to recognise when greedy gives the wrong answer.

About 45 minIntermediate4 exercises

You will be able to

  • Describe a greedy algorithm as a sequence of locally best, never-undone choices
  • Make change greedily and schedule the most non-overlapping bookings by earliest end time
  • Explain why the choice of greedy rule matters, using counterexamples
  • Recognise problems where greedy fails and a more thorough method is needed

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.