The word "algorithm" appears everywhere: news articles blame algorithms for polarization, companies advertise algorithmic recommendations, and regulators debate algorithmic accountability.

Most explanations of what an algorithm actually is either stay too abstract to be useful or dive straight into code that loses most readers.

This article takes a different approach. It explains algorithms in plain language (what they are, the main types, how they scale, and how the algorithms you interact with daily actually work) without requiring any programming background.

The name "algorithm" comes from the 9th-century Persian mathematician Muhammad ibn Musa al-Khwarizmi. His work Al-Kitab al-mukhtasar fi hisab al-jabr wa-l-muqabala (from which we also get "algebra") laid out systematic ways to solve linear and quadratic equations.

Al-Khwarizmi's step-by-step solution procedures were so influential that the Latinized form of his name, algorismus, came to describe any systematic calculation procedure. The modern computational meaning developed in the 20th century as computer science emerged as a discipline.


What Is an Algorithm?

An algorithm is a finite sequence of step-by-step instructions for solving a problem or completing a task. Each algorithm comes with three elements.

  • Input: data or information the algorithm starts with
  • Process: a defined sequence of steps applied to the input
  • Output: the result after the process completes

Algorithms do not belong only to computers. Take a recipe as an example. It takes ingredients as input, sets out a sequence of preparation steps as process and delivers a dish as output. Driving directions make up an algorithm and so does a medical triage checklist and the calculation rules on a tax form.

What makes computer algorithms distinctive is that the instructions must be precise enough for a machine to execute without ambiguity. A recipe that says "add salt to taste" is usable by a human who can taste.

The computer cannot run that instruction as it needs "add 1.5 grams of salt." Complete and unambiguous specification is what computers call for.

Every algorithm has to be finite. It has to stop after a set number of steps and give an output. If an algorithm goes on forever without giving any result, even though each step is correct, that algorithm has failed.

This seems obvious but is non-trivial in practice: the Halting Problem, proven by Alan Turing in 1936, shows that there is no general algorithm that can determine, for all possible programs and inputs, whether a given program will eventually halt or run forever.[11]

This was one of the foundational theoretical results in computer science.

An algorithm does not think. It executes. The intelligence, or the bias, in an algorithm comes from the humans who designed it, chose what to optimize for, and decided what data to train it on.


Why Algorithms Matter Beyond Computing

Understanding algorithms has become a practical necessity for non-programmers because algorithms now make or influence decisions that directly affect your life:

  • What content you see on social media
  • Whether your loan application is approved
  • Which candidates a company's hiring tool flags for human review
  • How your insurance premium is calculated
  • Which news stories appear at the top of your search results
  • What products are recommended to you and at what price

Algorithmic decision-making has a vast scale. Daily, more than 3 billion users have their news feed ranked by Facebook's news feed algorithm (Meta, 2023).[7]

Automated hiring screening tools process millions of job applications annually; a 2021 Harvard Business School report found that 88% of employers agreed that qualified high-skill candidates are screened out by automated systems (Fuller et al., 2021).[4]

For virtually every adult in developed economies, credit scoring algorithms affect access to mortgages, car loans and rental housing.

These decisions bring algorithmic systems that are not neutral because they encode choices about what to prioritize, what data to use and what tradeoffs to make. Knowing how algorithms work in general terms gives you the tools to ask better questions about the specific ones that affect you.


Types of Algorithms: The Main Categories

Sorting Algorithms

A sorting algorithm rearranges a collection of items into a defined order. Sorting is one of the most fundamental operations in computing because so many other tasks depend on data being sorted first.

Bubble sort is the simplest sorting algorithm: compare pairs of adjacent items and swap them if they are in the wrong order and keep going until no more swaps are necessary. It is easy to grasp but very slow on large datasets.

Merge sort. This uses a "divide and conquer" approach by splitting the list in half, sorting each half recursively and then merging the two sorted halves. Merge sort is far more efficient than bubble sort.

Quicksort selects a "pivot" element, partitions all other elements into those smaller and those larger than the pivot, and recursively sorts both partitions. Quicksort is typically the fastest general-purpose sorting algorithm in practice and is used in many programming language standard libraries.

Timsort, which was created by Tim Peters in 2002, is a hybrid sorting algorithm that comes from merge sort and insertion sort. This design gives it strong performance on real-world data, where ordered runs of elements are common.

One of those invisible choices that affects billions of executions each day, Timsort is now the default sorting algorithm in Python, Java and Android.

Search Algorithms

A search algorithm finds a specific item in a collection.

Linear search is the simplest method: go through each item one by one until you find what you want or run out of things to look at. This method will work on any list, sorted or not, though it gets slow as the collection grows.

Binary search is dramatically faster - but only works on sorted data. It works by repeatedly halving the search space:

  1. Look at the middle element of the list
  2. If it matches the target, you are done
  3. If the target is smaller, eliminate the upper half and repeat with the lower half
  4. If the target is larger, eliminate the lower half and repeat with the upper half

Binary search finds any item in a list of one million in at most 20 comparisons. Linear search could take up to one million. The difference is the algorithm - not the hardware.

Hash tables work by computing a mathematical function called a hash that maps a key straight to the spot where its matching value is stored. They do not search through items one by one.

A well-implemented hash table achieves O(1) lookup - the same time regardless of whether the table contains 100 items or 100 million.

Fast lookup is what hash tables provide for databases, caches, dictionaries in programming languages as well as many other systems.

Graph Algorithms

Maps, social connections, computer networks and supply chains are examples of networks that appear in many real problems. Graph algorithms handle navigation through these structures.

Dijkstra's algorithm (1959), developed by Dutch computer scientist Edsger W.[12] Dijkstra, finds the shortest path between two points in a network - the core technology behind every GPS navigation system.

It systematically explores paths from a starting point, always extending the shortest known path first, until the destination is reached.

Today's navigation systems use variants of Dijkstra's algorithm combined with heuristics such as A* search to handle road networks with millions of nodes efficiently.

PageRank, developed by Larry Page and Sergey Brin at Stanford, was the foundational algorithm for Google search. It treats the web as a graph where websites are nodes and hyperlinks are edges. A page's rank is determined by how many other pages link to it, weighted by the rank of those linking pages.

Pages linked to by many high-rank pages get high ranks too. The thinking was that the collective judgment of the web as expressed through linking behavior gave a better measure of quality than the page's content alone.

Brin and Page published the initial PageRank paper in 1998 (Brin & Page, 1998), describing the algorithm that formed the basis of Google.[1]

They noted that the simple link-counting approach produced dramatically better results than the keyword-density approaches dominant at the time - because links represent deliberate editorial choices, not just textual proximity.

Encryption Algorithms

Encryption algorithms turn readable data (plaintext) into unreadable data (ciphertext). Only authorized parties holding the correct key can reverse the transformation. Secure communications across HTTPS, encrypted messaging and digital payments all depend on encryption algorithms.

RSA encryption (named for Rivest, Shamir, and Adleman, 1977) exploits the mathematical asymmetry between multiplying two large prime numbers (easy) and factoring their product back into the original primes (extremely hard).[13]

With this asymmetry comes public key cryptography. Anyone can use a public key that is shared openly to encrypt a message, yet only the owner of the matching private key can decrypt it.

AES (Advanced Encryption Standard), adopted by the US government in 2001 after an open international competition, is the symmetric encryption algorithm used for the bulk of encrypted data worldwide. Unlike RSA, AES is a symmetric algorithm (the same key encrypts and decrypts), making it far faster for large data volumes.

Machine Learning Algorithms

Machine learning algorithms do not follow rules that are explicitly programmed and instead they learn patterns from data. That makes this distinction important.

Spammers will eventually pick up the rules that a traditional spam filter uses by putting them in emails. If the email has the words "free money," mark it as spam.

Spam filtering works by training a machine learning algorithm on millions of labeled examples (spam vs. not spam). The algorithm finds statistical patterns that tell them apart and makes a model that applies those patterns to new emails. Spam patterns that no human wrote rules for can be detected by it.

Major machine learning algorithm families include:

CategoryWhat It DoesExample Applications
Supervised learningLearns from labeled training data to predict outputs for new inputsEmail spam detection, image recognition, credit scoring
Unsupervised learningFinds patterns in unlabeled data without predefined categoriesCustomer segmentation, anomaly detection, topic modeling
Reinforcement learningLearns by trial and error, receiving rewards for good actionsGame-playing AI (AlphaGo), robotics, recommendation tuning
Deep learning (neural networks)Learns hierarchical representations of data through layered processingNatural language processing, image generation, voice recognition
Large language models (LLMs)Predicts likely next tokens from massive text training dataAI assistants, code generation, document summarization

The final category is large language models. This marks the most recent major change in what algorithms are capable of.

Models like GPT-4 and its successors are trained on hundreds of billions of words of text and learn statistical patterns so rich that they can write coherently, answer questions, translate languages, and reason through multi-step problems - despite being, at their core, algorithms that predict which word (technically, which token) should come next.


Big O Notation: How Algorithms Scale

The most important concept for comparing algorithms is Big O notation - a way of describing how an algorithm's resource requirements (typically time) grow as the input size grows.

It is like answering the question of what happens to processing time when I double the input size.

Big O ClassNameWhat It MeansExample
O(1)Constant timeSame time regardless of input sizeLooking up a value by key in a hash table
O(log n)LogarithmicTime grows slowly; doubling input adds one stepBinary search
O(n)LinearTime grows proportionally with inputLinear search, reading a list
O(n log n)LinearithmicSlightly worse than linearMerge sort, quicksort
O(n)QuadraticDoubling input quadruples timeBubble sort, nested loops
O(2^n)ExponentialDoubling input squares the timeBrute-force password cracking
O(n!)FactorialGrows faster than any polynomialBrute-force traveling salesman problem

Why This Matters in Practice

An O(n) algorithm processing 1,000 items takes 1,000,000 operations. Processing 10,000 items takes 100,000,000 operations - 100 times more work for 10 times more data. At 1,000,000 items, it becomes practically unusable.

An O(n log n) algorithm that deals with 1,000,000 items does about 20,000,000 operations and that is manageable. When it comes to systems that work versus ones that do not at scale, the difference between O(n) and O(n log n) is huge.

Large-scale problems make it matter far more to choose the right algorithm than to get faster hardware. When the input is very large, you cannot use faster computers to buy your way out of a bad algorithm.

The Traveling Salesman Problem, which is to find the shortest route that visits each city exactly once, has no known polynomial-time solution. Checking all 20! routes amounts to 2.4 quintillion possibilities and that is computationally infeasible even on the fastest hardware when there are 20 cities.

One of the deepest open questions in computer science is the gap between "fast algorithm exists" and "no fast algorithm known." It is the P vs.

The NP problem, asking whether every problem that can be verified quickly can also be solved quickly, still has no answer. Its resolution would have major effects on cryptography, optimization and artificial intelligence.


Recommendation Algorithms: How Netflix, Spotify, and YouTube Decide What You See

Recommendation systems are among the most economically important algorithms ever built. Netflix estimates that its recommendation algorithm drives approximately 80% of content watched on the platform (Gomez-Uribe & Hunt, 2015).[5]

Launched in 2015, Spotify's Discover Weekly became one of the most used features in music streaming history by generating 5 billion streams in its first year. To understand how they work takes grasping two methods:

Collaborative Filtering

Collaborative filtering makes recommendations based on the behavior of users similar to you.

The logic: if User A and User B have rated 200 films similarly, and User A loved a film that User B hasn't seen, recommend that film to User B. At scale, this is done using matrix factorization techniques that represent all users and all items as vectors in a mathematical space, where proximity indicates similarity. Users and items that are "close" in this space are considered compatible.

Netflix's early recommendation system was based on a matrix factorization approach that won the famous Netflix Prize - a $1 million competition run from 2006 to 2009, challenging teams to improve Netflix's recommendation algorithm by at least 10%.

BellKor's Pragmatic Chaos, the winning team, improved by 10.06% using a complex ensemble of matrix factorization techniques (Koren, Bell & Volinsky, 2009).[6] This competition spurred academic work on collaborative filtering and the algorithms that came out of it affected how recommendation systems were designed for years.

Collaborative filtering works well when there is abundant user data. It struggles with the cold start problem: a new user with no history has no similar users to learn from.

Content-Based Filtering

Content-based filtering analyzes the attributes of items you have engaged with and recommends similar items based on those attributes. Spotify's content-based recommendation system analyzes audio features of tracks (tempo, key, energy, danceability, acousticness, speechiness) and recommends tracks with similar characteristics.

Content-based filtering works from the first interaction and does not require learning from other users. Its limitation is that it tends to recommend more of what you already know - it cannot easily introduce genuinely novel tastes.

Hybrid Systems

Modern platforms combine both approaches, often with additional signals:

  • Context signals: Time of day, device being used, what activity the user is doing
  • Recency weighting: Recent behavior may be more predictive than older behavior
  • Diversity injection: Deliberately introducing varied recommendations to avoid filter bubbles
  • Engagement optimization: Training models not just on what users click but on longer-term satisfaction signals
  • Session-based models: Recurrent neural networks or transformer architectures that model the sequence of interactions in a single session, predicting what comes naturally next

The last point raises a critical issue: what you optimize for determines what the algorithm produces.[10] A recommendation algorithm optimized for clicks will surface click-bait. An algorithm optimized for watch time will surface content that is addictive rather than valuable.

An algorithm optimized for user satisfaction three days down the line will work differently from one optimized for immediate engagement.

Stray et al.'s research from 2021 looked at recommendation engines built to optimize for raw engagement and found that these systems create a systematic incentive to show emotionally provocative content. Such content draws more immediate engagement even when users say they do not want more of it.

Instead of being designed on purpose to cause harm, this feedback loop is how recommendation algorithms can push out extreme or misleading content.


How Search Algorithms Work

Modern search engines are not a single algorithm but a pipeline of many:

Crawling: Web crawlers (automated bots) follow hyperlinks across the web and download page content for indexing. Google's crawler is called Googlebot; it processes an estimated billions of pages continuously to keep the index current.

Indexing: Downloaded pages are processed, parsed, and stored in a massive inverted index - a data structure that maps every word to the pages that contain it. Google's index reportedly covers hundreds of billions of pages, making it one of the largest data structures ever built.

Ranking: When a user submits a query, the search engine retrieves all indexed pages containing the query terms and ranks them using hundreds of signals. Google's ranking uses over 200 factors, including:

  • PageRank (link authority)
  • Content relevance and quality signals
  • User behavior signals (click-through rate, dwell time)
  • Page speed and mobile-friendliness
  • Freshness of content for time-sensitive queries
  • Semantic understanding of query intent
  • E-E-A-T signals stand for Experience, Expertise, Authoritativeness and Trustworthiness and they are especially weighted for health, financial and legal content.

BERT and neural ranking: Since 2019, Google has used BERT (Bidirectional Encoder Representations from Transformers) - a deep learning model - to understand the semantic meaning of queries and passages, dramatically improving performance on natural language questions.

At launch, Google said BERT affected about 1 in 10 English language searches (Nayak, 2019).[8] Neural ranking systems that followed have gone further. Google's MUM (Multitask Unified Model) and Gemini-based systems have extended multimodal understanding to include images, video and cross-language queries.


The Algorithmic Accountability Problem

As algorithms make increasingly consequential decisions, a new field of research has emerged examining how to make algorithmic decision-making fair, interpretable, and accountable.

Algorithmic fairness research has produced multiple competing mathematical definitions of fairness - which, disturbingly, are often mathematically incompatible.

Equalized false positive rates (same error rate across demographic groups), equal positive predictive value (predictions equally accurate across groups), and demographic parity (equal selection rates across groups) cannot all be simultaneously satisfied in most real-world scenarios (Chouldechova, 2017).[3]

Better engineering cannot fix this as a technical limit. It is a fundamental mathematical rule that calls for explicit value choices on which form of fairness to prioritize in order for algorithms to be fair.

Algorithmic explainability addresses the problem that many high-performing machine learning algorithms (particularly deep neural networks) are "black boxes" - even their designers cannot fully explain why they produce a specific output for a specific input.

Automated decisions call for interpretable models in consequential decisions such as credit scoring or parole recommendations, which the EU's GDPR requires a right to explanation and that has put legal pressure on companies to use models that can be explained.


When Algorithms Get It Wrong: Failure Modes

Understanding how algorithms work also means understanding how they fail.

Feedback loops. Even if users do not want more of it, a recommendation system that feeds its own choices back into its training data can keep pushing out polarizing or emotionally charged content.

Training data bias: Machine learning algorithms learn from historical data. If that data reflects historical discrimination (as hiring decisions, loan approvals, or policing patterns often do), the algorithm will learn to replicate that discrimination.

A landmark 2018 study by Joy Buolamwini and Timnit Gebru (Buolamwini & Gebru, 2018) found that commercial facial recognition systems had substantially higher error rates for darker-skinned women than lighter-skinned men - because training data underrepresented darker-skinned faces, and the systems had learned from a biased sample.[2]

Distribution shift: An algorithm trained on data from one context may fail when deployed in another. A fraud detection model trained on pre-pandemic spending patterns performed poorly in 2020 when spending patterns changed abruptly.

When there is little labeled training data available, a content moderation model trained on English-language toxic speech can do poorly on non-English languages.

Goodhart's Law. A measure stops being a good measure once it becomes a target and an algorithm optimized for a proxy metric such as clicks, engagement or five-star ratings will find ways to boost that metric that do not meet the underlying goal.

This is why Amazon famously discovered that its internal hiring algorithm had learned to penalize resumes containing the word "women's" - because it was trained on historical promotion data in a male-dominated organization, and historical patterns became encoded as targets (Reuters, 2018).[9]

Adversarial attacks. By designing inputs specifically built to fool them, machine learning systems can be deliberately manipulated. Small, imperceptible changes added to images have been shown by researchers to make image recognition systems misclassify objects with high confidence.

Malicious actors who manipulate recommendation systems, spam filters and ad-targeting algorithms is a constant arms race and this is not a theoretical worry.


Key Takeaways

Algorithms are not magic, not neutral and not inherently mysterious. Each one is a structured way to solve problems and its characteristics show what problems it is good for and how well it scales.

The core concepts that matter for non-programmers:

  • An algorithm is a step-by-step process that transforms input into output - nothing more, nothing less.
  • Big O notation describes scaling: The difference between O(log n) and O(n) is the difference between a system that handles a million items easily and one that cannot.
  • Recommendation systems bring together collaborative and content-based filtering. They are built to work with signals that may or may not match what users really want.
  • Algorithms encode choices: What to optimize for, what data to use, and what tradeoffs to make are human decisions embedded in algorithmic systems.
  • Algorithmic failures are predictable. Feedback loops, training bias, distribution shift and proxy metric optimization are failure modes that are known and not surprises.
  • Fairness is mathematically complex. There are several legitimate definitions of fairness that cannot be mathematically compatible with each other. That makes "fair algorithms" a value choice rather than a purely technical problem.

People make the specific choices that build the algorithms shaping what you see, read, buy and get approved for. Knowing how those algorithms work is the first step to judging whether the choices benefit you.


Sources & Further Reading

  1. Brin, S., & Page, L. (1998). The anatomy of a large-scale hypertextual web search engine. Proceedings of the 7th International Conference on World Wide Web, 107-117. View source
  2. Buolamwini, J., & Gebru, T. (2018). Gender shades: Intersectional accuracy disparities in commercial gender classification. Proceedings of Machine Learning Research, 81, 1-15.
  3. Chouldechova, A. (2017). Fair prediction with disparate impact: A study of bias in recidivism prediction instruments. Big Data, 5(2), 153-163. View source
  4. Fuller, J., et al. (2021). Hidden Workers: Untapped Talent. The book was published by Harvard Business School and Accenture.
  5. Gomez-Uribe, C. A., & Hunt, N. (2015). The Netflix recommender system: Algorithms, business value, and innovation. ACM Transactions on Management Information Systems, 6(4), 1-19. View source
  6. Koren, Y., Bell, R., & Volinsky, C. (2009). Matrix factorization techniques for recommender systems. Computer, 42(8), 30-37. View source
  7. Meta. (2023). How Facebook's News Feed Algorithm Works. Meta Transparency Center.
  8. Nayak, P. (2019). Understanding Searches Better than Ever Before. Google Blog.
  9. Reuters. (2018, October 10). Amazon scraps secret AI recruiting tool that showed bias against women. Reuters.
  10. Stray, J., et al. (2021). What are you optimizing for? Aligning recommender systems with human values. Proceedings of the ICML 2020 Workshop on Challenges in Deploying and Monitoring Machine Learning Systems.
  11. Turing, A. M. (1936). On computable numbers, with an application to the Entscheidungsproblem. Proceedings of the London Mathematical Society, s2-42(1), 230-265. View source
  12. Dijkstra, E. W. (1959). A note on two problems in connexion with graphs. Numerische Mathematik, 1(1), 269-271. View source
  13. Rivest, R. L., Shamir, A., & Adleman, L. (1978). A method for obtaining digital signatures and public-key cryptosystems. Communications of the ACM, 21(2), 120-126. View source