Skip to Content
Python Algorithms: Mastering Basic Algorithms in the Python Language, Second Edition
book

Python Algorithms: Mastering Basic Algorithms in the Python Language, Second Edition

by Magnus Lie Hetland
September 2015
Intermediate to advanced
320 pages
12h 30m
English
Apress
Content preview from Python Algorithms: Mastering Basic Algorithms in the Python Language, Second Edition

CHAPTER 7

image

Greed Is Good? Prove It!

It’s not a question of enough, pal.

— Gordon Gekko, Wall Street

So-called greedy algorithms are short-sighted, in that they make each choice in isolation, doing what looks good right here, right now. In many ways, eager or impatient might be better names for them because other algorithms also usually try to find an answer that is as good as possible; it’s just that the greedy ones take what they can get at this moment, not worrying about the future. Designing and implementing a greedy algorithm is usually easy, and when they work, they tend to be highly efficient. The main problem is showing that they do work—if, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python 3: Project-based Python, Algorithms, Data Structures

Python 3: Project-based Python, Algorithms, Data Structures

Mashrur Hossain

Publisher Resources

ISBN: 9781484200551Purchase book