Glossary · AI and computing

Algorithm design

Published 25 Apr 2026 · Updated 11 Nov 2026 · 15 min read

Algorithm design is the work of turning a precisely stated problem into a step-by-step procedure proven correct and efficient enough for its intended inputs. It also means analyzing how the work grows. In AI systems, designers choose what the system optimizes and how it learns from data.

  • Running time growth can make the same task take seconds or years as input size grows.
  • A greedy shortcut can suit one system and fail another, so correctness needs a proof.
  • An AI model can meet its metric while failing the user if the target is poorly chosen.

What algorithm design means

A problem describes what an acceptable answer looks like for every input. An algorithm supplies the steps to find that answer. Design means finding a procedure that is correct, efficient and clear enough to examine. The specification comes first, including which output is acceptable and which constraints apply. The definitions below distinguish these ideas across computing and artificial intelligence.

SourceDateDefinition, in its own wordsWhat it adds
NIST, Dictionary of Algorithms and Data StructuresDateEntry modified 9 November 2020Definition, in its own words“A computable set of steps to achieve a desired result.”What it addsThe shortest standard definition, from a US standards body
IEC 60050, International Electrotechnical Vocabulary, 171-05-07Date29 March 2019Definition, in its own words“finite set of well-defined rules for the solution of a problem in a finite number of steps”What it addsAdds that the rules and the steps are finite
Donald E. Knuth, The Art of Computer Programming, Volume 1DateFirst edition 1968, third edition 1997Definition, in its own words“a finite set of rules that gives a sequence of operations for solving a specific type of problem”What it addsFive properties: finiteness, definiteness, input, output and effectiveness
Jeff Erickson, AlgorithmsDateFirst edition, June 2019Definition, in its own words“An algorithm is an explicit, precise, unambiguous, mechanically-executable sequence of elementary instructions, usually intended to accomplish a specific purpose.”What it addsA modern textbook stresses that a machine must be able to follow every step
MIT OpenCourseWare 6.006, Introduction to AlgorithmsDateSpring 2020Definition, in its own wordsAn algorithm is a “Procedure mapping each input to a single output (deterministic)”, and it “solves a problem if it returns a correct output for every problem input”.What it addsSeparates the problem from the procedure that solves it
OECD, definition of an AI systemDateUpdated 8 November 2023Definition, in its own words“a machine-based system that, for explicit or implicit objectives, infers, from the input it receives, how to generate outputs such as predictions, content, recommendations, or decisions”What it addsIn AI, the objective is part of the design

MIT's Spring 2020 introduction to algorithms treats a problem specification as a relation between inputs and correct outputs. A deterministic algorithm maps each input to one output, and it solves the problem when every such output satisfies that relation. Knuth's 1997 edition of The Art of Computer Programming, Volume 1, lists five properties: finiteness, definiteness, input, output and effectiveness. These require termination and precisely defined, executable steps. In section 1.1, he also emphasizes that usefulness needs "a reasonable number" of steps, not merely a finite count.

The practice predates electronic computers. Euclid's Elements included a greatest common divisor algorithm about 300 BC. The word comes from al-Khwarizmi, who wrote a book of arithmetic rules about 825, according to NIST's Dictionary of Algorithms and Data Structures. Modern algorithm design evaluates two separate qualities: correctness and efficiency. Textbooks call an algorithm efficient when its running time is polynomial in the size of the problem. That classification concerns growth, not a promise about seconds on a particular machine.

In machine learning, the designer chooses an objective function, often expressed as a loss function, together with the data and evaluation method. The optimization algorithm may use gradient descent to seek a low value, without guaranteeing the minimum. Model training runs an algorithm that produces a model. Inference applies that model to new inputs. These are separate design tasks: learning parameters and using them need not have the same computational cost.

How an algorithm is designed

A useful workflow separates the required result and its constraints from the procedure that produces it. Write down the assumptions before choosing an algorithm, then revisit them when measurements reveal a mismatch.

Number 1

Specify the problem

Define the inputs, acceptable outputs and constraints. State a verifiable condition for success and a cost model. Include latency, memory, request cost, fairness and privacy where they apply.

Number 2

Choose an approach

Select a paradigm and a data structure together. Divide and conquer suits problems that split into smaller instances, and dynamic programming suits problems whose subproblem answers can be stored and reused.

Number 3

Prove correctness

Use induction, a loop invariant or an exchange argument to justify every permitted case. Test implementation behavior and edge cases that a mathematical proof does not cover.

Number 4

Analyze the cost

Use big-O notation to describe time and memory complexity. Separate worst case, average case and amortized cost. Polynomial running time marks efficiency in the textbook sense.

Number 5

Know the limits

Check the lower bound before seeking a faster algorithm. Comparison sorting needs about n lg n comparisons. For NP-hard problems, distinguish exact answers from approximation guarantees.

Number 6

Measure in use

For AI systems, separate the objective from reported metrics. Combine offline model validation with a live A/B test. Monitor for feedback loops and drift after deployment.

No comparison-based sorting algorithm can beat about n lg n comparisons in the worst case. The lower bound is 22 for 10 items and 18,488,885 for a million. For NP-hard problems such as the shortest tour, nobody knows a polynomial-time exact algorithm. An approximation algorithm offers a proven ratio, while heuristics do not. For example, greedy load balancing guarantees a result within twice the optimum. The guarantee belongs to that specific problem, not every use of the approach.

How running time grows with input size

The same input can take nanoseconds or longer than the age of the universe to process, depending on the algorithm. As inputs grow, differences in growth rates widen. Faster hardware does not remove that gap.

Figure 1 · Textbook worst-case formulas, page team calculationComparison counts at different sizesChoose an input size to compare growth on a logarithmic scale, check the sorting lower bound, and view illustrative times.
Input size, n
Worst-case comparisons for n = 1,000, log scaleTextbook formulasLinear searchn1,000 comparisonsabout 1 microsecondBinary search, sorted input⌊lg n⌋ + 110 comparisonsabout 10 nanosecondsInsertion sortn(n − 1)/2499,500 comparisonsabout 499 microsecondsMerge sortat most n lg nat most 9,966 comparisonsabout 10 microsecondsSorting lower bound⌈lg n!⌉8,530 comparisonsNo comparison sort can do betterTry every subset2^nabout 1.07 × 10^301 comparisonsabout 10^284 years, off the chartDashed lines: one second and one year of work at one billion comparisons a second.Worst-case comparisonsLower bound for any comparison sortBeyond 10^32, off the chart

At 10 items, every method finishes in about a microsecond or less. Even trying all 1,024 subsets appears instant at this scale.At 100 items, insertion sort needs 4,950 comparisons and merge sort at most 664. Enumerating every subset would take about 40 trillion years.At 1,000 items, insertion sort needs nearly half a million comparisons. Merge sort needs fewer than 10,000, about 50 times fewer.At one million items, insertion sort takes about eight minutes and merge sort 0.02 seconds. Binary search needs 20 comparisons on sorted data.

Page team calculations use textbook worst-case formulas and assume one billion comparisons a second. These are estimates, not measured runtimes.

Linear search grows with n. Binary search grows with lg n, but requires sorted input. Insertion sort grows with n squared, while merge sort grows with n lg n. At a million items, their counts are roughly 500 billion and 20 million comparisons. Trying every subset grows as 2^n, becoming impractical beyond a few dozen items. Search, sorting and enumeration solve different tasks. The figure compares growth patterns, not interchangeable algorithms.

Growth can outweigh processor speed. The CLRS textbook's second edition gives merge sort about 100 seconds on a computer 100 times slower. Insertion sort takes 2,000 seconds for the same million numbers. PCAST's December 2010 report describes a planning model that would have taken 82 years in 1988. In 2003, it could be solved in roughly one minute. The speedup factor of roughly 43 million combined factors of 43,000 from algorithms and 1,000 from processors. These algorithmic breakthroughs show why complexity matters alongside hardware.

When a greedy algorithm is not optimal

Taking the largest available coin feels natural when making change. This algorithm commits to each local choice without revisiting it. That can save work, but a fast decision rule does not automatically minimize the final number of coins.

Figure 2 · Greedy against dynamic programming, page team calculationLocal choices against optimal changeChoose a coin system and amount. Compare greedy choices with the fewest coins needed to make change.
Coin system
Amount
Amount 6: greedy against the fewest coinsPage team calculationDenominations: 1, 3, 4Greedy, largest first: 3 coins411Fewest possible: 2 coins33Greedy uses 1 coin more than needed
Greedy for this amount3 coinsLargest denomination first, never revisited
Dynamic programming2 coinsBuilds on the best answer for every smaller amount
Amounts from 1 to 3,000 where greedy loses749Not canonical

US coins are canonical. Greedy matches the optimum for every tested amount from 1 to 3,000 cents.At 6, picking 4 then two 1s uses three coins instead of two 3s. It fails at 749 amounts up to 3,000.At 140, the rule uses eight stamps instead of two 70s. It fails at 1,860 amounts up to 3,000 in this postage system.This greedy answer is optimal for the selected amount. One matching answer does not establish a guarantee for every amount.

The page team compared greedy with dynamic programming for every amount from 1 to 3,000 in each system.

Greedy change-making minimizes coins for the US set of 1, 5, 10 and 25 cents. With denominations 1, 3 and 4, its first failure occurs at 6 cents. Kleinberg and Tardos's postage example first fails at 30. At 140, it needs eight stamps instead of two. A system where the rule is optimal for every amount is called canonical. Pearson's 1994 test checks that property in time polynomial in the number of coin types, without trying amounts one by one.

Dynamic programming solves each amount exactly by reusing answers for smaller amounts. The coin choice becomes a comparison of complete alternatives, not just denominations. The same issue appears in the 0/1 knapsack problem. In Kleinberg and Tardos's 11 kg example, greedy selection by value per kilogram reaches $35, while the optimum is $40. A local-choice algorithm belongs where a proof supports it, as with minimum spanning trees. Otherwise, speed alone cannot establish optimality.

What happens when AI optimizes a metric

Choosing what to maximize changes what people see. In recommendation systems, an AI model follows the objective built into its algorithm. Ranking algorithms can prioritize clicks, viewing time or another signal. That choice has consequences beyond the reported score.

Figure 3 · Made-up catalogue of six videosThree goals for video recommendationsSwitch between clicks, watch time and a usefulness guardrail. See three recommendations and their results per 1,000 impressions.
Rank by
Three slots, ranked by clicksMade-up catalogueTeaser clipSlot 1Click rate 12%Watched 0.6 minutes per clickRated useful by 20%Reaction clipSlot 2Click rate 9%Watched 1.5 minutes per clickRated useful by 35%ExplainerNot shownClick rate 5%Watched 6.0 minutes per clickRated useful by 80%Full lectureNot shownClick rate 4%Watched 18.0 minutes per clickRated useful by 35%TutorialNot shownClick rate 6%Watched 4.5 minutes per clickRated useful by 85%News recapSlot 3Click rate 7%Watched 2.5 minutes per clickRated useful by 70%
Clicks per 1,000 impressions93Impressions split evenly across the three slots
Minutes watched127Per 1,000 impressions
Clicks on videos rated useful37%From a follow-up survey
Clicks per 1,000 impressions50Impressions split evenly across the three slots
Minutes watched430Per 1,000 impressions
Clicks on videos rated useful70%From a follow-up survey
Clicks per 1,000 impressions60Impressions split evenly across the three slots
Minutes watched248Per 1,000 impressions
Clicks on videos rated useful78%From a follow-up survey
RecommendedNot shownDropped by the guardrail

Ranking by clicks yields 93 clicks per 1,000 impressions, but just 127 watched minutes. Only 37% of clicks reach videos rated useful.Ranking by watch time yields 430 minutes and 70% usefulness. It includes a long lecture rated useful by only 35% of viewers.Excluding videos below 60% usefulness reduces watch time to 248 minutes. Usefulness reaches 78%, the highest share among these three lists.

This six-video catalogue and its numbers are made up to illustrate trade-offs, not measure a real recommendation system.

YouTube shifted from clicks toward time watched in March 2012 because clicks did not reliably indicate interest. Its September 2016 recommendation paper described clickbait that viewers did not finish. It also reported tuning the ranking objective through live A/B testing, since offline experiments did not always match live results. Facebook's January 2018 shift toward meaningful interactions illustrates a different trade-off. Facebook's 31 January 2018 results said changes made in late 2017, such as showing fewer viral videos, cut time spent by roughly 50 million hours a day.

Goodhart's 1975 observation is often quoted as "when a measure becomes a target, it ceases to be a good measure", wording usually credited to Marilyn Strathern (1997). DeepMind calls it specification gaming when a system meets an objective literally but misses its intent. Sculley and colleagues (2015) warn that a model can shape its own future training data. Google's Rules of Machine Learning call a launch easy only when no metric gets worse, so teams pair metric selection with guardrail metrics and live tests.

How algorithm design approaches compare

The table distinguishes strategies by their guarantees, costs and failure modes. Brute force checks every candidate. Divide and conquer splits work into smaller instances. Backtracking and branch and bound explore alternatives. A randomized algorithm uses chance, while learned approaches fit machine learning models to observations.

ParadigmIdeaWhen it fitsWhat it guaranteesTypical costClassic exampleMain risk
Brute forceIdeaTry every candidateWhen it fitsTiny inputs, or a reference answer for testingWhat it guaranteesExact, if every candidate is checkedTypical costOften exponential: 2^n subsets of n itemsClassic exampleChecking all subsetsMain riskBlows up as n grows
Divide and conquerIdeaSplit into smaller instances, solve them recursively, combineWhen it fitsProblems that split cleanlyWhat it guaranteesExactTypical costMerge sort: Θ(n log n)Classic exampleMerge sortMain riskThe combine step or recursion overhead
GreedyIdeaTake the best local choice at each stepWhen it fitsProblems with a proof that local choices add upWhat it guaranteesOptimal only where a proof existsTypical costUsually a sort plus one passClassic exampleMinimum spanning trees, US coinsMain riskSilent wrong answers on other inputs
Dynamic programmingIdeaCache the answers to subproblemsWhen it fitsOverlapping subproblemsWhat it guaranteesExact optimumTypical costStates times work per state: Θ(nW) for knapsackClassic example0/1 knapsack, change-makingMain riskToo many states for memory or time
Backtracking, branch and boundIdeaTry choices and abandon those that cannot winWhen it fitsSearch spaces with good boundsWhat it guaranteesExact when the search finishesTypical costExponential in the worst caseClassic examplePuzzles, schedulingMain riskWeak bounds explore everything
RandomizedIdeaMake random choicesWhen it fitsInputs an adversary might chooseWhat it guaranteesExpected time or probability boundsTypical costQuicksort: typically O(n log n), Θ(n²) in the worst caseClassic exampleQuicksort, randomized hashingMain riskBad luck or a weak random source
ApproximationIdeaRun in polynomial time with a proven ratio to the optimumWhen it fitsNP-hard optimization problemsWhat it guaranteesA stated performance guaranteeTypical costPolynomialClassic exampleGreedy load balancing, a 2-approximationMain riskThe ratio may be loose, and some ratios are impossible unless P = NP
HeuristicsIdeaUsually work, with no guaranteeWhen it fitsSpeed matters more than a proofWhat it guaranteesNoneTypical costFast by designClassic exampleTraveling salesman heuristics a few percent from optimalMain riskNo warning when they fail
Learned, machine learning basedIdeaFit a model to data and use it as, or to search for, the algorithmWhen it fitsPlenty of representative dataWhat it guaranteesMeasured, not provenTypical costTraining plus inferenceClassic exampleLearned indexes, AlphaDevMain riskDistribution shift, metric gaming, no worst-case bound for a learned model

Read guarantees before comparing speed. An exact algorithm must finish its search, and its complexity may make that impractical. Optimization algorithms can instead provide a stated approximation ratio or a measured result without a proof of optimality. Heuristic creation requires another distinction: a heuristic guiding exact search is not necessarily an algorithm without guarantees. A* can use an estimate that never overestimates to guide exact search. Learned methods depend on the distribution of the observations they fit.

How algorithm design developed

The field grew from written arithmetic procedures into formal computation, complexity theory and learned methods. These milestones track different contributions rather than a single line of progress. Each changed what designers could describe, analyze or implement.

  1. About 300 BC

    A procedure for common divisors

    Euclid's Elements contained an algorithm for finding the greatest common divisor of two natural numbers. It appeared in Book 7, Propositions 1 and 2.

  2. About 825

    Arithmetic gives algorithms their name

    Al-Khwarizmi wrote a book of arithmetic rules. His name later gave the word algorithm its form, as NIST's Dictionary of Algorithms and Data Structures explained.

  3. 1843

    Steps for an analytical engine

    Ada Lovelace published notes on Babbage's Analytical Engine. Note G included steps for computing Bernoulli numbers, presenting a procedure for the proposed machine.

  4. 1936

    A model of mechanical computation

    Alan Turing's paper On Computable Numbers, received on 28 May 1936, defined a model of mechanical computation that later work used to reason about what machines can compute.

  5. December 1959

    A method for shortest paths

    Edsger Dijkstra published his shortest-path method in the journal Numerische Mathematik. It settles the closest unvisited node first, a greedy strategy that works when no edge has a negative length.

  6. May 1971

    A framework for computational difficulty

    Stephen Cook presented his NP-completeness paper at STOC, held from 3 to 5 May 1971. Richard Karp followed with 21 problems in 1972.

  7. October 1986

    Learning through back-propagated errors

    Rumelhart, Hinton and Williams published Learning representations by back-propagating errors in Nature on 9 October 1986. The method passes error signals backward through a network to adjust its weights during training.

  8. June 2023

    Machine-discovered sorting reaches a library

    AlphaDev's machine-discovered sorting routines appeared in Nature on 7 June 2023. The routines had already entered the LLVM libc++ library on 8 April 2022.

The limits of algorithm design

Proofs and benchmarks establish different kinds of confidence. Neither removes every constraint on a deployed algorithm. Some limits concern what can be computed economically. Others concern changed conditions, hostile behavior or the gap between a score and a useful result.

NP-hard problems

Unless P equals NP, no algorithm solves these problems exactly in polynomial time. Cook's 1971 and Karp's 1972 results explain why designers consider approximations or heuristics.

No free lunch

Wolpert and Macready's April 1997 result rules out universal superiority across all problems. An algorithm's gains over one class are offset elsewhere, so performance claims need assumptions about the task.

Distribution shift

The December 2020 WILDS benchmark describes accuracy losses when training and test distributions differ. NIST warned in January 2023 that data can become detached from their intended context.

Metric gaming

Every objective is a proxy for what people need. Pushed hard, a system finds ways to score well that miss the goal, so the gap needs watching after launch.

Adversarial inputs

Crosby and Wallach's August 2003 study showed chosen input degrading trees and hash tables into lists, dropping up to 71% of server traffic. Randomized hash functions address collision attacks.

Training cost

Patterson and colleagues estimated in April 2021 that training GPT-3 used 1,287 MWh of electricity. These were their estimates for another organization's model, not measurements by this page.

From algorithm design to working software

We design and implement algorithms and machine learning models for recommendation, forecasting, search and optimization. Evaluation and monitoring start with the use case, not only after launch. PixelPlex, a software engineering company founded in 2007, builds AI and machine learning systems alongside its blockchain work.

PixelPlex case icon

Our 2022 CheckNFT.iO case study shows distinct algorithms serving different tasks. One model compares token names to catch manipulated symbols or replaced letters. Image similarity search builds embeddings with convolutional neural networks, then finds the closest image with a nearest neighbor algorithm. Wash trading detection connects interacting groups and looks for unusual patterns.

  1. Use-case AI systems

    We scope AI development services around the use case, selecting and customizing models with a combination of custom and open-source tools.
  2. Method selection and tuning

    Our machine learning development work selects methods and algorithms for personalized recommendations, demand forecasting and route optimization, with ongoing support and maintenance.
  3. Predictive model validation

    Through data science services, we develop predictive models and refine their accuracy and efficiency. Deliverables include a model accuracy and validation report.
  4. Evaluation and drift monitoring

    We set evaluation baselines and monitoring before anything ships in agentic AI development. After launch, our AI deployment services include real-time observability and drift detection.
  5. Routes tested in simulation

    Our 2022 warehouse automation case used a digital twin to plan order routes and test operational scenarios before the equipment purchasing stage.

Discuss the choices behind your next algorithm

Share the problem, constraints and evaluation goals. We can discuss an algorithm or model design that fits those requirements.

Discuss your project

Algorithm design FAQ

What is algorithm design in simple terms?

Algorithm design means turning a clearly stated problem into steps that produce a correct output. The work includes specifying permitted inputs, showing why the procedure is correct and estimating its cost. A useful design makes those claims explicit, so they can be reviewed rather than assumed.

How does an algorithm differ from a program?

An algorithm is a procedure, while a program implements that procedure in a language for a machine. The distinction separates the proposed solution from its executable form. Reviewing a program therefore includes checking whether its behavior preserves the algorithm's intended outputs and assumptions.

What does big-O notation tell developers?

Big-O describes an upper bound on how resource use grows with input size. It can express running time or memory complexity. It does not give seconds for a specific machine. Worst-case, average-case and amortized claims also answer different questions, so the stated assumptions matter.

Why do greedy algorithms sometimes fail?

A greedy algorithm's locally attractive choice can prevent a better complete solution. With coins valued 1, 3 and 4, taking 4 first makes 6 require three coins instead of two. This shortcut needs a proof for the particular problem. Dynamic programming compares alternatives using stored answers for smaller cases.

What does NP-hard mean for a practical problem?

An NP-hard problem has no known polynomial-time exact algorithm. That does not say every small instance is impractical. A team can consider an approximation with a stated performance guarantee, an exact search that may be expensive, or a heuristic whose answer quality must be checked.

How does algorithm design work in machine learning?

Algorithm design in machine learning combines the objective, optimization method, data and evaluation process. Training produces a model, while inference applies it to new examples. An offline metric helps evaluate candidates, but it does not settle deployment decisions. Live results and resource requirements also need examination.

How can AI teams avoid optimizing the wrong metric?

Teams pair the optimization objective with guardrail metrics that represent outcomes the team does not want to sacrifice. Test changes through live A/B experiments rather than relying only on offline scores. Monitor distribution shift and feedback loops, including whether recommendations change the model's future learning material.
Sources (35)

Get updates about blockchain, technologies and our company

We will process the personal data you provide in accordance with our Privacy policy. You can unsubscribe or change your preferences at any time by clicking the link in any email.

Follow us on social networks and don't miss the latest tech news

  • facebook
  • X
  • linkedin
  • instagram
Stay tuned and add value to your feed