🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Greedy Algorithms Quiz: all 8 questions

Greedy Algorithms Quiz · Question 2 of 8

What is the best way to check whether a greedy idea is wrong?

What is the best way to check whether a greedy idea is wrong?

  1. A.Run it on the sample input only
  2. B.Look for a counter-example
  3. C.Check that it is O(n)
  4. D.Ask whether it uses sorting
Answer & explanation

Correct answer: Look for a counter-example

One input where greedy fails proves it's incorrect (e.g. coin change with [1, 3, 4]).

Can you get the rest right without peeking?

Take the timed Greedy Algorithms Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →