What Is An Algorithm
An algorithm is a list of clear steps that, if followed in order, takes you from a starting situation to a finished one. Nothing more. The word sounds technical because we have learned it from computers, but the oldest …
There is more than one way to understand this. If you have only been taught one, you have been taught less than you deserve.
There is more than one way to understand this. If you have only been taught one, you have been taught less than you deserve.
An algorithm is a list of clear steps that, if followed in order, takes you from a starting situation to a finished one. Nothing more. The word sounds technical because we have learned it from computers, but the oldest algorithm in your house is probably a recipe. When your nani teaches you to make daal chawal, she is not handing you mystery. She is handing you an algorithm. Wash the masoor daal twice. Soak the chawal for ten minutes. Heat oil in the patila. Add zeera, then onion, then haldi. The order matters. The amounts matter. If you swap two steps, you do not get daal chawal, you get something else.
A second example, this time without a stove. Every morning before school, you sort your school bag. You have an English copy, a maths copy, an Urdu copy, a science textbook, a geometry box, a lunch box, and a water bottle. There are at least two ways to pack the bag. You can pick things up at random and shove them in until the bag is full. Or you can put the heaviest items at the bottom, the books in the middle, and the soft lunch box on top. The second way is also an algorithm. The steps are: pick the heaviest, place at the bottom, repeat with the next heaviest, then place soft items on top. This algorithm has a name in computer science. It is called sorting.
A third example from the gali. You and seven cousins have decided to play pidi cricket on a Sunday. Someone needs to decide the batting order. The eldest cousin says, the order is, openers first, then strong hitters, then those who take wickets, then the youngest who is still learning. That sentence is an algorithm for assigning roles. The input is eight kids and their abilities. The output is a numbered list, one to eight, of who bats when. If a new cousin shows up halfway, the algorithm tells you how to slot her in without arguing for ten minutes. Algorithms are useful exactly because they remove the need to re-decide every time.
What makes a good algorithm. Three things. One, every step is clear enough that another person, or a computer, can follow it without guessing. Two, the algorithm finishes. It does not loop forever, the way a confused conversation can. Three, it produces the result you actually wanted. A daal chawal recipe that ends with raw rice has all the steps but the wrong outcome. The same is true of code. A program that runs without error but gives the wrong answer is a broken algorithm wearing a working face.
Why this matters. The story of computing in the next twenty years is the story of millions of small algorithms doing work that used to be done by hand. Some will be written by people in San Francisco and Beijing. Many should be written by people in Lahore and Karachi and Quetta and Gilgit, because the work the country needs done is work only people who live here understand. An algorithm for sorting school admissions in a low-fee Pakistani school is not the same as one for a Boston charter. An algorithm for splitting biraadari inheritance under our family law is not the same as a Western estate planner. The first step toward writing those is realising you already think in algorithms every day. The recipe, the bag, the batting order. You are not starting from zero. You are starting from a lifetime of practice you did not know had a name.
Estimated time: 12 min