The Ultimate Greedy Algorithm

Nick Mazuk
7 min readNov 12, 2019

I’ve always been interested in how people make decisions. These can be very simple methods of figuring out the best path or incredibly complex.

But recently I’ve heard of the greedy algorithm. And this has gotten me thinking about what the best way to make decisions in the world is.

The greedy algorithm is a problem-solving heuristic that’s actually used quite a bit in computer science, but how does it translate to the real world? I mean, the real world actually has people in it. Can a simple mathematical algorithm work in a world with people?

Today, we are going to look at the greedy algorithm in a practical sense. We will find out why the greedy algorithm doesn’t necessarily work and develop a better solution: the ultimate greedy algorithm. Finally, we will look into how you can implement the ultimate greedy algorithm into your life.

The Greedy Algorithm

The greedy algorithm is relatively straightforward. It begins by asking one simple question: “Which option produces the best result for me?” It ends with choosing that result.

In other words, choose what is best for you.

It’s that simple. If you are choosing where to go for dinner, ask “does A or B sound better”? Go where it sounds better. If wondering whether or not you should skydive, ask whether the enjoyment outweighs the possibility of death. Choose which option is better for you.

The Downside

But what about the following case:

You are an elementary school student looking for some entertainment during break. You have a few friends, but not any that want to play with you. But you see this one kid alone in the corner that looks vulnerable. You ask yourself, “should I make fun of this kid (which would provide entertainment) or should I continue being bored?” The greedy algorithm says to choose the former.

Or look at this other real-life case: Snapchat’s IPO.

On Thursday, March 2, 2017, Snap Inc. went public on the New York Stock Exchange. And like many stocks on their IPO, investors gobbled up the stocks. And yet this was a very overpriced stock. There wasn’t even anything that this stock offered beyond the right to say that you owned part of Snap Inc. There were no dividends, and unlike most stocks, no voting rights. Anyone who bought the stock on its IPO would have lost 32% since then.

For reference, the IPO (initial public offering) is when a company goes public on the stock exchange. In other words, public investors can buy shares of a company even if they aren’t insiders to the company.

This sounds like a losing deal, but it wasn’t for everyone. You see, the venture capitalists were able to sell their shares (which many bought years earlier for cheap). They profited. The same is true with Snap Inc. The company is a losing business model because they have no income. So instead of trying to find yet more venture capitalists, they sold shares of their company. Essentially, they raised over 2 billion dollars in one day for no loss of power.

The greedy algorithm told them to get free money at the expense of anyone who invested. It was essentially just one big, giant, legal scam.

Snap Inc. Stock Price Since their IPO

The greedy algorithm doesn’t always produce results that are bad for others. It’s just that it doesn’t take other people into account whatsoever. It’s only about which option works best for you. It just happens that this can turn out poorly for others, whether that be bullying or a scam.

And this is the greedy algorithm. It’s one way in which you can live your life and make choices, but there are others. So let’s next look at the polar opposite of the greedy algorithm.

The Selfless Algorithm

While the greedy algorithm looks at what will be the best for you, the selfless algorithm looks at what would be the best for the other person. Here, the question becomes: “would A or B be better for the other person?”

Choose what is best for them.

Obviously, the selfless algorithm doesn’t have the same flaws as the greedy algorithm. You can’t bully another person in your self-interest because you don’t care about your own self-interest. You would instead befriend the other student; that’s what is best for them. And instead of creating a legal scam during an IPO, you would actually give your investors something worth investing in.

You can’t hurt someone else if you are always doing what’s in their own best interest.

The Downside

You can, however, hurt yourself.

Think of every case in which the greedy algorithm hurts another person. If you were that other person and used the selfless algorithm, you would be hurting yourself because you would let the greedy algorithm hurt you.

But it’s not that simple. You would never get anything that you want done because what you want to accomplish is irrelevant. All that matters is the other person.

And now we get to the ultimate greedy algorithm.

The Ultimate Greedy Algorithm

So far, we’ve looked at the greedy algorithm and the selfless algorithm. But what if I told you they were actually the same thing.

What if I told you that the best thing for yourself is doing the best thing for everyone else?

I know this may at first be a difficult idea to accept, but let’s look at the extreme case. If everyone used the ultimate greedy algorithm, you would have over 7 billion people working for you to make your life better.

That’s a lot of people.

Compare that to the standard greedy algorithm (which only has one person) and the standard selfless algorithm (which has zero people).

The Rational

Now that assumes an ideal world, but it works even in a not ideal world. Why, because it involves long-term thinking.

The standard greedy and selfless algorithms are short-term algorithms. The full question is really “what would benefit [me or them] now?” By moving to the long-term, we can avoid the downfalls of each of these algorithms.

The short-term algorithms fail to realize that each of our decisions with others is not in isolation with one another. If you use the greedy algorithm against someone else, they are more likely to use the greedy algorithm against you because that’s in their best interest. And when you use the selfless algorithm, it’s advantageous for the other person to use the greedy algorithm against you.

However, in the long run, both of these things are a bad thing. But by doing what is best for others in ways that also help you, you move to the ultimate greedy algorithm and transfer to the long-term.

Implementing the Ultimate Greedy Algorithm

I realize that I haven’t given the most convincing argument for the ultimate greedy algorithm, but that’s because Nicky Case already has an amazing illustration of this very point:

Nicky Case — The Evolution of Trust

I highly encourage you to go play through this interactive tutorial on trust.

Ultimately, pay attention to the copykitten strategy. That strategy combines the benefits of using the ultimate greedy algorithm while limiting the downsides that we are not in the ideal world.

In Nicky Case’s explorable explanation, the Cheater uses the greedy algorithm and the Cooperator is the closest thing to the selfless algorithm.

Spoiler Alert!

In the simulation, the end result is that the best way to instill trust is by using the copykitten method. This method starts off with always choosing to cooperate and then only cheats after the other person cheats twice in a row. This is equivalent to use the selfless algorithm for the first few interactions and then only move to the greedy algorithm if they start using the greedy algorithm on you.

It also shows why you don’t solely want to use the greedy algorithm or the selfless algorithm. Cooperator is the selfless algorithm equivalent and was the first strategy to die in most of the simulations. And while the Cheater (greedy algorithm) always outpaced everyone else in the short-term, it eventually died off because the copycats and copykitten’s helped each other while not helping the cheater.

Over time, though, the copycats and copykitten’s helped each other in such a way that was equivalent to the ultimate greedy algorithm. Because by helping each other, they are also helping themselves.

This overall provides a way to transition to the ultimate greedy algorithm without harming you or other people.

Conclusion

As you might have guessed by now, I prefer the ultimate greedy algorithm over each of the other ones.

Though there is one thing to note: the ultimate greedy algorithm is not based on greed. I call it the ultimate greedy algorithm because it just happens to be that I believe it the best strategy to do well for yourself. So for those who wish to be greedy, using the ultimate greedy algorithm is your best solution.

And yet for those who want to do good for the world, the ultimate greedy algorithm is also your best solution.

Instead of being based on greed, the ultimate greedy algorithm is based on trust and empathy. It’s based on realizing that other people are just like you and that by doing the best thing you can for them, they will do the best thing they can for you.

So here’s my challenge to you: try to use the ultimate greedy algorithm in your life. It will help you and everyone else out. Use it and try to help get all 7+ billion people on earth to help each other out.

And if you are worried that there won’t be anyone else to help you out, there’s at least one. You can make it two.

--

--