This article was accepted into the corpus but its outbound wikilinks were never NER-processed — typical at the deepest BFS hop or when the run's entity cap was reached. No expansion funnel to show.
| Knuth–Morris–Pratt | |
|---|---|
| Name | Knuth–Morris–Pratt |
| Type | String-search algorithm |
| Authors | Donald Knuth; Vaughan Pratt; James H. Morris |
| First published | 1977 |
| Input | Text and pattern strings |
| Output | Occurrences of pattern in text |
| Time complexity | O(n + m) |
| Space complexity | O(m) |
Knuth–Morris–Pratt Knuth–Morris–Pratt is a linear-time string-search algorithm developed to find occurrences of a pattern within a text. The algorithm is notable for combining ideas from algorithmic theory by Donald Knuth, Vaughan Pratt, and James H. Morris, and for influencing subsequent work in pattern matching by researchers associated with institutions such as Stanford University, Massachusetts Institute of Technology, and Bell Labs. Important contemporary connections include applications described by authors affiliated with Carnegie Mellon University, University of California, Berkeley, and Princeton University.
Knuth–Morris–Pratt emerged from research communities linked to Stanford University, Princeton University, Massachusetts Institute of Technology, Bell Labs, and Carnegie Mellon University and rapidly influenced textbooks by Donald Knuth, Robert Sedgewick, and Jon Bentley. The algorithm is taught alongside classical methods such as the Rabin–Karp algorithm, the Boyer–Moore algorithm, and automaton-based approaches from Noam Chomsky-inspired formal language studies. Its relevance spans software engineering groups at Microsoft Research, Google, and IBM Research and appears in practical systems designed by teams at Apple Inc., Oracle Corporation, and Facebook.
The algorithm preprocesses a pattern and then scans a text; seminal expositions appear in monographs by Donald Knuth, Vaughan Pratt, and James H. Morris and in course materials from Harvard University, Yale University, and Columbia University. KMP avoids redundant comparisons by consulting a precomputed table related to borders of the pattern; comparable methods are discussed by John Hopcroft and Jeffrey Ullman in automata theory. Implementations in libraries from GNU Project, Boost (C++) Libraries), and languages such as Java (programming language), Python (programming language), and C (programming language) demonstrate engineering trade-offs addressed in software by teams at Red Hat and Canonical (company).
The key preprocessing step builds a failure function (often called the prefix function) that records longest proper prefix-suffix relationships; formal treatments cite contributions by Edsger W. Dijkstra and Robert Tarjan on related automata notions. Exposition often references pattern border concepts explored alongside Andrei A. Markov-inspired finite-state analyses and connections to work by Stephen Cook on formal languages. This function is analogous to partial match tables used in pattern matching libraries at Apache Software Foundation projects and in utilities from Free Software Foundation distributions.
The algorithm achieves worst-case time complexity O(n + m), a result emphasized in lectures by Leslie Lamport and in surveys by Michael Rabin and Richard Karp who developed probabilistic alternatives. Space complexity is linear in the pattern length, a point compared to constant-space streaming designs by researchers at AT&T and Bell Labs Research. Empirical performance comparisons include benchmarks produced by teams at Intel Corporation and NVIDIA as well as profiling discussed in publications at ACM and IEEE conferences.
Numerous variants extend the baseline algorithm: adaptations for multiple-pattern matching inspired by Aho–Corasick algorithm authors at Dartmouth College; bit-parallel optimizations influenced by work at University of California, Los Angeles; and suffix automaton integrations developed in research groups at University of Warsaw and École Polytechnique Fédérale de Lausanne. Other extensions address approximate matching studied by groups at University of Helsinki and Weizmann Institute of Science and GPU-accelerated versions implemented by labs at NVIDIA Research and Intel Labs.
KMP appears in text editors from Microsoft Corporation, Emacs, and Vim and in search utilities produced by GNU Project and Apple Inc.. Bioinformatics tools at European Bioinformatics Institute and National Center for Biotechnology Information employ related substring search methods, while data processing frameworks at Apache Software Foundation projects such as Hadoop incorporate pattern-matching modules. Database systems from Oracle Corporation and PostgreSQL use substring search primitives that trace conceptual lineage to prefix-function ideas. Implementations and teaching materials are distributed by repositories like GitHub and research codebases at arXiv and institutional sites for MIT OpenCourseWare and Coursera.
The algorithm was presented jointly by Donald Knuth, Vaughan Pratt, and James H. Morris, each affiliated with institutions including Stanford University and Princeton University, and arose in the context of 1970s advances in algorithm design documented in proceedings of ACM SIGACT and IEEE Symposium on Foundations of Computer Science. The collaboration followed prior work by Morris Pratt individually and intersected with contemporary string algorithms such as Boyer–Moore algorithm and Rabin–Karp algorithm. Subsequent research by scholars at University of Cambridge, University of Oxford, and University of Edinburgh expanded theoretical understanding and adoption across software engineering curricula at Massachusetts Institute of Technology and Carnegie Mellon University.
Category:String searching algorithms