
Greedy Algorithms and the Gospel: How Computer Science Helps Us Appreciate God More
hHave you sent an SMS or used GPS navigation recently? Whether you were aware of it or not, you used a greedy algorithm, a subject studied in computer science. But greedy algorithms can do much more than just energy technology. They and the ideas behind them can also be spiritually instructive.
Before diving further, let’s define our terms. An algorithm is a step-by-step process of solving a problem, and a greedy algorithm is one that only takes steps that maximize short-term value. For example, consider a cashier tasked with making 30 cents of change with as few coins as possible. He will start by choosing the highest value coin, a quarter. Then, it remains for her to make 5 cents in change, then she will choose a nickel. With that, he completed the task using only two coins. Note that there are other but inferior solutions, such as choosing 2 cents and 2 nickels.
By reflecting on such connections, Christians can learn to draw close to Christ « greedily » in all that he commands us to do.While « greedy » generally has a negative connotation elsewhere, here in computing, it only refers to having a short-term focus. This focus allows greedy algorithms to be straightforward and intuitive, compared to other algorithms that require more steps or use more resources. In short, greedy algorithms are popular because they are simple yet effective.
However, simplicity can quickly turn into naivety, as honing in the short term isn’t always best in the long run. For example, when making changes with stamps, greedy algorithms can be incredibly inefficient. Consider the task of making 80 cents of postage with 60, 40 and 1 cent stamps. A greedy algorithm would choose the highest value stamp first, the 60-cent one. With 20 cents left, the algorithm can only pick 1-cent stamps, which it has to do 20 times. Imagine receiving such a letter! The optimal solution would instead have been to choose two 40-cent stamps, even if individually they do not have such a high value.
Greedy algorithms can not only be inefficient, they can also fail altogether. This time, consider the task of making 10 cents of postage with 5 and 8 cent stamps. The greedy algorithm first chooses the highest value stamp, the 8 cent one. After that, with 2 cents left, it crashes.
These examples illustrate the general principle of computer science that a greedy algorithm only works optimally when its problem space is organized in a particular way, such as coin denominations are. Only then do they produce the best solutions.
fFrom one point of view, religions are also concerned with problems and solutions: what is wrong with the world and what should be done in response. Framed this way, practicing Christianity is like following a greedy algorithm. Life isn’t primarily about working more or converting more people (long-term endeavor). Instead, Christianity is primarily about being in relationship with the creator God. Christians are called to spend time with him, both in his word and in prayer, both individually and collectively. We must know him personally not just intellectually, look for his face not just his hands. Our first priority, our only thing, is simply being with the Lord.
But can pursuing a relationship in the short term actually be good in the long run as well? After all, Aaron’s sons were supposedly trying to relate to God in their own way Leviticus 10, but God was displeased and killed them because of their “unauthorized fire.” In 2 Samuel 6God fatally “struck [Uzzah] down” while he and other Israelites were in the midst of worship! As serious as this group was in pursuing God, they disobeyed his commandments regarding the proper transportation of the ark. In both of these cases, the relationship seems secondary to holiness. Perhaps we need to follow God’s commandments perfectly before we can expect to be with him.
This may be the essence of the Old Covenant, but everything changes when Jesus enters the picture. Christ died for all, fulfilling the just requirement of the law and reconciling believers to their holy Father. Now, despite our sin, we are adopted into God’s family, where a direct relationship with God is possible. Indeed, it is optimal, as we are commanded to « abide » in the Lord (John 15:4), “get close” to him (James 4:8), “looks for” it (Psalm 27:8) and « see it » (Psalm 34:4–5). What should be most satisfying in the short term is ultimately what is best in the long run as well.
But remember, the short-term goal of this algorithm only works because the problem space is organized in a particular way: Christ shed His blood for sinners. This new privileged lifestyle that Christians lead is only possible thanks to his sacrifice. God could have abandoned us in our sin, but he didn’t and for this we can live as his children, simply. Similarly, coin denominations could have been randomly counted, but they are not and because of this, changes can easily be made. Both of these simplicities cannot be taken for granted: they were « deeply bought » and intentionally designed. Only thanks to specific dispositions can Christians live « greedily ».
OROf course, analogies have their limits. Sin still afflicts us, and we often do not desire the things of God in the short term. For this, it is worth clarifying that the greedy lifestyle is Christian only if it makes its short-term decisions based on God’s standards. Otherwise, it boils down to mere hedonism or legalism.
Others might argue that greed focused on immediacy seems immoral and at odds with biblical patience and forbearance. While believers are certainly called to serve the Lord, this occurs only after a relationship with him has been established and nurtured. Relationship comes first. However, it seems ironic that Christians shouldn’t want, but should be greedy. However, it is not the desire itself that matters, but what the object of the desire is. The desire for more wealth and worldly possessions, as it is usually interpreted as « greed », is certainly reprehensible. But the desire to know more about God, as « greed » is now being rephrased, is central to our faith.
Also, greedy algorithms characterize Christianity well, especially when compared to other religions or worldviews. In a conference on comparative religion, CS Lewis argued that while there are many distinctive aspects of Christianity, for example the incarnation or resurrection, they also appear in other religions. What is truly unique about Christianity, Lewis noted, is grace. Philip Yancey elaborates on this point further, write,
The idea of God’s love that comes to us freely, without constraints, seems to go against every instinct of humanity. The Buddhist Eightfold Path, the Hindu doctrine of karma, the Jewish covenant, and the Muslim law code—all of these offer a way to gain approval. Only Christianity dares to make God’s love unconditional.
Unconditional love is the foundation of our faith and allows us to courageously seek a relationship with our Heavenly Father.
A biblical story Perhaps a good illustration of greedy faith is the account of Mary and Martha. Luke contrasts these two sisters with Mary sitting and listening at Jesus’ feet, while Martha is « distracted » by her service. When Martha protests, Jesus actually praises Mary for having chosen « the good part » and the only « necessary » thing. Martha’s acts of service were respectable, but they were secondary to just being with the servant king.
In addition to highlighting the Lord’s priorities for believers, this passage also exemplifies His inclusive grace. In New Testament times, women were often discouraged or even excluded from study. However, Jesus breaks with culture and invites Mary to teach her. This wasn’t just a one-time exception for a friend; Jesus was known for associating with the humble and marginalized, to the point that the Pharisees considered him « a glutton and a drunkard, a friend of tax collectors and sinners » (Matthew 11:19). Jesus embodied grace consistently, in his life and in his death, when he was admirable and when it was taboo.
grace and greed, alliances and computers. We may be tickled to think about these connections, but what difference can they make in the end?
By reflecting on such connections, Christians can learn to draw close to Christ « greedily » in all that he commands us to do. The main point of Christianity is still the relationship with God, but those who truly know him are forced to go out to love and serve the world. As we serve our neighbors, let us be alert to some of the various pitfalls that await us. First, one can serve but be « anxious and troubled about many things, » as Martha was. Second, one can serve but with bitterness or reluctance in the heart (2 Corinthians 9:6–7). Finally, one can serve but have self-centered or malevolent intentions, like the Pharisees. God is not happy with any of these attitudes. It’s not just about the shares themselves; the way they are made also matters. In fact, apart from him, nothing can be done. Therefore the relationship with God comes first, especially if one has to serve.
God reveals himself through this world (Psalm 8:3–4) and across unexpected domains such as computer science. While « greed, » understood traditionally, is certainly bad, « greedy algorithms, » understood scientifically, are not. In fact, greedy algorithms can actually help frame the gospel in a refreshing new way. They have much to teach us about God, his extravagant grace, and what we should do in response. Let us have an understanding heart and a willingness to put those lessons into practice.