Knuth–Morris–Pratt algorithm
E94984
The Knuth–Morris–Pratt algorithm is a classic linear-time string-searching algorithm that efficiently finds occurrences of a pattern within a text by precomputing a prefix function to avoid redundant comparisons.
All labels observed (2)
| Label | Occurrences |
|---|---|
| Knuth–Morris–Pratt algorithm canonical | 2 |
| "Fast Pattern Matching in Strings" | 1 |
How this entity was disambiguated
This entity first appeared as the object of triple T799184 — resolving that mention is where its identity was fixed. The disambiguator weighed these candidate entities and picked the highlighted one (or “None”, minting a new entity). This is how homonymy is resolved: the same surface form can point to different entities.
Target entity: Knuth–Morris–Pratt algorithm Context triple: [Donald E. Knuth, knownFor, Knuth–Morris–Pratt algorithm]
-
A.
IAS machine
The IAS machine was an early electronic stored-program computer designed by John von Neumann and his colleagues at the Institute for Advanced Study, serving as a prototype for many subsequent computer architectures.
-
B.
Look-and-say sequence
The look-and-say sequence is a famous integer sequence where each term is generated by verbally describing the digits of the previous term, studied for its surprising combinatorial and growth properties.
-
C.
Introduction to Algorithms
Introduction to Algorithms is a widely used, comprehensive textbook on algorithms and data structures, renowned for its rigorous yet accessible coverage of theoretical and practical topics in computer science.
-
D.
Turing machine
A Turing machine is an abstract computational model that manipulates symbols on an infinite tape according to a set of rules, providing a formal foundation for the concept of algorithm and computability.
-
E.
Introduction to the Theory of Computation
Introduction to the Theory of Computation is a widely used textbook in theoretical computer science that covers formal languages, automata, computability, and complexity theory.
- F. None of above. chosen
- G. Unsure - the case is ambiguous/there is not enough information to decide.
Target entity: Knuth–Morris–Pratt algorithm Target entity description: The Knuth–Morris–Pratt algorithm is a classic linear-time string-searching algorithm that efficiently finds occurrences of a pattern within a text by precomputing a prefix function to avoid redundant comparisons.
-
A.
IAS machine
The IAS machine was an early electronic stored-program computer designed by John von Neumann and his colleagues at the Institute for Advanced Study, serving as a prototype for many subsequent computer architectures.
-
B.
Look-and-say sequence
The look-and-say sequence is a famous integer sequence where each term is generated by verbally describing the digits of the previous term, studied for its surprising combinatorial and growth properties.
-
C.
Introduction to Algorithms
Introduction to Algorithms is a widely used, comprehensive textbook on algorithms and data structures, renowned for its rigorous yet accessible coverage of theoretical and practical topics in computer science.
-
D.
Turing machine
A Turing machine is an abstract computational model that manipulates symbols on an infinite tape according to a set of rules, providing a formal foundation for the concept of algorithm and computability.
-
E.
Introduction to the Theory of Computation
Introduction to the Theory of Computation is a widely used textbook in theoretical computer science that covers formal languages, automata, computability, and complexity theory.
- F. None of above. chosen
Statements (50)
| Predicate | Object |
|---|---|
| instanceOf |
deterministic algorithm
ⓘ
linear-time algorithm ⓘ pattern-matching algorithm ⓘ string-search algorithm ⓘ |
| application |
pattern matching in compilers
ⓘ
search in DNA or protein sequences ⓘ search in network intrusion detection systems ⓘ text editors search functionality ⓘ |
| authorsOfOriginalPaper |
Donald E. Knuth
ⓘ
James H. Morris ⓘ
surface form:
James H. Morris Jr.
Vaughan Pratt ⓘ
surface form:
Vaughan R. Pratt
|
| avoids |
backtracking in the text
ⓘ
re-examining characters in the text ⓘ |
| category | exact string matching algorithms ⓘ |
| comparedWith |
Boyer–Moore string-search algorithm
ⓘ
surface form:
Boyer–Moore algorithm
Rabin–Karp algorithm ⓘ naive string-search algorithm ⓘ |
| describedIn |
Knuth–Morris–Pratt algorithm
self-linksurface differs
ⓘ
surface form:
"Fast Pattern Matching in Strings"
|
| field |
algorithms
ⓘ
computer science ⓘ stringology ⓘ |
| hasPhase |
preprocessing phase
ⓘ
search phase ⓘ |
| input |
pattern string
ⓘ
text string ⓘ |
| introducedIn | 1977 ⓘ |
| keyIdea |
avoid redundant comparisons by reusing previous match information
ⓘ
precompute longest proper prefix which is also suffix for each pattern position ⓘ |
| namedAfter |
Donald E. Knuth
ⓘ
surface form:
Donald Knuth
James H. Morris ⓘ Vaughan Pratt ⓘ |
| output | starting indices of pattern occurrences in text ⓘ |
| preprocessingPhaseComplexity | O(m) ⓘ |
| property |
guaranteed worst-case linear time
ⓘ
runs in time linear in the length of the text plus pattern ⓘ stable performance independent of alphabet size ⓘ |
| purpose | find occurrences of a pattern in a text ⓘ |
| searchPhaseComplexity | O(n) ⓘ |
| spaceComplexity | O(m) ⓘ |
| taughtIn |
data structures and algorithms curricula
ⓘ
undergraduate algorithms courses ⓘ |
| timeComplexity | O(n + m) ⓘ |
| timeComplexityBestCase | O(n) ⓘ |
| timeComplexityWorstCase | O(n + m) ⓘ |
| typicalRepresentation | pseudocode in algorithm textbooks ⓘ |
| usesConcept |
border of a string
ⓘ
failure function ⓘ prefix function ⓘ proper prefix ⓘ proper suffix ⓘ |
How these facts were elicited
The pipeline generated the facts above by prompting gpt-5.1 with this entity's name + description and the instruction below.
You are a knowledge base construction expert. Given a subject entity and a description of it, return factual statements that you know for the subject as a JSON list of dictionaries(triples), where keys must be "subject", "predicate" and "object". The number of facts may be very high, between 25 to 50 or more, for very popular subjects. For less popular subjects, the number of facts can be very low, like 5 or 10. # Requirements - If you don't know the subject at all, return an empty list. - If the subject is not a named entity, return an empty list. - Include at least one triple where predicate is "instanceOf". - Do not get too wordy. - Separate several objects into multiple triples with one object.
Subject: Knuth–Morris–Pratt algorithm Description of subject: The Knuth–Morris–Pratt algorithm is a classic linear-time string-searching algorithm that efficiently finds occurrences of a pattern within a text by precomputing a prefix function to avoid redundant comparisons.
Referenced by (3)
Full triples — surface form annotated when it differs from this entity's canonical label.