Commentz-Walter algorithm
In computer science, the Commentz-Walter algorithm is a string searching algorithm invented by Beate Commentz-Walter. Like the Aho–Corasick string matching algorithm, it can search for multiple patterns at once. It combines ideas from Aho–Corasick with the fast matching of the Boyer–Moore string-search algorithm. For a text of length n and maximum pattern length of m, its worst-case running time is O(mn), though the average case is often much better. GNU grep once implemented a string matching algorithm very similar to Commentz-Walter.
In computer science, the Commentz-Walter algorithm is a string searching algorithm invented by Beate Commentz-Walter. Like the Aho–Corasick string matching algorithm, it can search for multiple patterns at once. It combines ideas from Aho–Corasick with the fast matching of the Boyer–Moore string-search algorithm. For a text of length n and maximum pattern length of m, its worst-case running time is O(mn), though the average case is often much better. GNU grep once implemented a string matching algorithm very similar to Commentz-Walter.
References
- Watson, Bruce William (1995-09-15). Taxonomies and toolkits of regular language algorithms . Eindhoven University of Technology . doi : 10.6100/IR444299 . ISBN 90-386-0396-7 . Wikipedia revision 1321675524, retrieved 2026-11-20 · retrieved 2026-11-19 · rev 1321675524
Cite this reference
MLA "Watson, Bruce William (1995-09-15). Taxonomies and toolkits of regular language algorithms . Eindhoven University of Technology . doi : 10.6100/IR444299 . ISBN 90-386-0396-7 . Wikipedia revision 1321675524, retrieved 2026-11-20." Watson, Bruce William (1995-09-15). 2026-11-19. https://en.wikipedia.org/wiki/Eindhoven_University_of_Technology. Accessed 24 November 2026.
Chicago "Watson, Bruce William (1995-09-15). Taxonomies and toolkits of regular language algorithms . Eindhoven University of Technology . doi : 10.6100/IR444299 . ISBN 90-386-0396-7 . Wikipedia revision 1321675524, retrieved 2026-11-20." Watson, Bruce William (1995-09-15). 2026-11-19. https://en.wikipedia.org/wiki/Eindhoven_University_of_Technology.
APA Watson, Bruce William (1995-09-15). (2026). Watson, Bruce William (1995-09-15). Taxonomies and toolkits of regular language algorithms . Eindhoven University of Technology . doi : 10.6100/IR444299 . ISBN 90-386-0396-7 . Wikipedia revision 1321675524, retrieved 2026-11-20. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Eindhoven_University_of_Technology
- grep: remove Commentz-Walter code · retrieved 2022-05-14 · rev 1321675524
Cite this reference
MLA "grep: remove Commentz-Walter code." 2022-05-14. https://git.savannah.gnu.org/cgit/grep.git/commit/src/kwset.c?id=57d32889c95e04a0f0237ec09538b22aa39fe908. Accessed 24 November 2026.
Chicago "grep: remove Commentz-Walter code." 2022-05-14. https://git.savannah.gnu.org/cgit/grep.git/commit/src/kwset.c?id=57d32889c95e04a0f0237ec09538b22aa39fe908.
APA encyclopegia.org. (2022). grep: remove Commentz-Walter code. Retrieved November 24, 2026, from https://git.savannah.gnu.org/cgit/grep.git/commit/src/kwset.c?id=57d32889c95e04a0f0237ec09538b22aa39fe908
- Average time complexity analysis of Commentz-Walter algorithm · retrieved 2026-11-19 · rev 1321675524
Cite this reference
MLA "Average time complexity analysis of Commentz-Walter algorithm." Dewasurendra, SD; Vidanagamachchi, SM (2018). 2026-11-19. https://doi.org/10.4038%2Fjnsfsr.v46i4.8630. Accessed 24 November 2026.
Chicago "Average time complexity analysis of Commentz-Walter algorithm." Dewasurendra, SD; Vidanagamachchi, SM (2018). 2026-11-19. https://doi.org/10.4038%2Fjnsfsr.v46i4.8630.
APA Dewasurendra, SD; Vidanagamachchi, SM (2018). (2026). Average time complexity analysis of Commentz-Walter algorithm. Retrieved November 24, 2026, from https://doi.org/10.4038%2Fjnsfsr.v46i4.8630
- Analysis of Multiple String Pattern Matching Algorithms · retrieved 2026-11-19 · rev 1321675524
Cite this reference
MLA "Analysis of Multiple String Pattern Matching Algorithms." a b c Akinul Islam Jony (2014). 2026-11-19. https://elvedit.com/journals/IJACSIT/wp-content/uploads/2014/09/IJACSIT-3402-AoMSPMA.pdf. Accessed 24 November 2026.
Chicago "Analysis of Multiple String Pattern Matching Algorithms." a b c Akinul Islam Jony (2014). 2026-11-19. https://elvedit.com/journals/IJACSIT/wp-content/uploads/2014/09/IJACSIT-3402-AoMSPMA.pdf.
APA a b c Akinul Islam Jony (2014). (2026). Analysis of Multiple String Pattern Matching Algorithms. Retrieved November 24, 2026, from https://elvedit.com/journals/IJACSIT/wp-content/uploads/2014/09/IJACSIT-3402-AoMSPMA.pdf
- a b c Commentz-Walter, Beate (1979). A String Matching Algorithm Fast on the Average (PDF) . International Colloquium on Automata, Languages and Programming . LNCS . Vol. 71. Graz, Austria: Springer. pp. 118– 132. doi : 10.1007/3-540-09510-1_10 . ISBN 3-540-09510-1 . Archived from the original (PDF) on 2017-10-10. Wikipedia revision 1321675524, retrieved 2026-11-20 · retrieved 2026-11-19 · rev 1321675524
Cite this reference
MLA "a b c Commentz-Walter, Beate (1979). A String Matching Algorithm Fast on the Average (PDF) . International Colloquium on Automata, Languages and Programming . LNCS . Vol. 71. Graz, Austria: Springer. pp. 118– 132. doi : 10.1007/3-540-09510-1_10 . ISBN 3-540-09510-1 . Archived from the original (PDF) on 2017-10-10. Wikipedia revision 1321675524, retrieved 2026-11-20." a b c Commentz-Walter, Beate (1979). 2026-11-19. https://web.archive.org/web/20171010223532/http://www.hs-albsig.de/studium/wirtschaftsinformatik/Documents/commentzwalterextab.pdf. Accessed 24 November 2026.
Chicago "a b c Commentz-Walter, Beate (1979). A String Matching Algorithm Fast on the Average (PDF) . International Colloquium on Automata, Languages and Programming . LNCS . Vol. 71. Graz, Austria: Springer. pp. 118– 132. doi : 10.1007/3-540-09510-1_10 . ISBN 3-540-09510-1 . Archived from the original (PDF) on 2017-10-10. Wikipedia revision 1321675524, retrieved 2026-11-20." a b c Commentz-Walter, Beate (1979). 2026-11-19. https://web.archive.org/web/20171010223532/http://www.hs-albsig.de/studium/wirtschaftsinformatik/Documents/commentzwalterextab.pdf.
APA a b c Commentz-Walter, Beate (1979). (2026). a b c Commentz-Walter, Beate (1979). A String Matching Algorithm Fast on the Average (PDF) . International Colloquium on Automata, Languages and Programming . LNCS . Vol. 71. Graz, Austria: Springer. pp. 118– 132. doi : 10.1007/3-540-09510-1_10 . ISBN 3-540-09510-1 . Archived from the original (PDF) on 2017-10-10. Wikipedia revision 1321675524, retrieved 2026-11-20. Retrieved November 24, 2026, from https://web.archive.org/web/20171010223532/http://www.hs-albsig.de/studium/wirtschaftsinformatik/Documents/commentzwalterextab.pdf
- Commentz-Walter, Beate. A String Matching Algorithm Fast on the Average . · retrieved 2025-11-10 · rev 1321675524
Cite this reference
MLA "Commentz-Walter, Beate. A String Matching Algorithm Fast on the Average ." Commentz-Walter, Beate. 2025-11-10. https://en.wikipedia.org/w/index.php?oldid=1321675524. Accessed 24 November 2026.
Chicago "Commentz-Walter, Beate. A String Matching Algorithm Fast on the Average ." Commentz-Walter, Beate. 2025-11-10. https://en.wikipedia.org/w/index.php?oldid=1321675524.
APA Commentz-Walter, Beate. (2025). Commentz-Walter, Beate. A String Matching Algorithm Fast on the Average . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1321675524
- grep: remove Commentz-Walter code . GNU . 2017-01-18. · retrieved 2025-11-10 · rev 1321675524
Cite this reference
MLA "grep: remove Commentz-Walter code . GNU . 2017-01-18." grep: remove Commentz-Walter code. 2025-11-10. https://en.wikipedia.org/w/index.php?oldid=1321675524. Accessed 24 November 2026.
Chicago "grep: remove Commentz-Walter code . GNU . 2017-01-18." grep: remove Commentz-Walter code. 2025-11-10. https://en.wikipedia.org/w/index.php?oldid=1321675524.
APA grep: remove Commentz-Walter code. (2025). grep: remove Commentz-Walter code . GNU . 2017-01-18. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1321675524
- Akinul Islam Jony. Analysis of Multiple String Pattern Matching Algorithms . · retrieved 2025-11-10 · rev 1321675524
Cite this reference
MLA "Akinul Islam Jony. Analysis of Multiple String Pattern Matching Algorithms ." Akinul Islam Jony. 2025-11-10. https://en.wikipedia.org/w/index.php?oldid=1321675524. Accessed 24 November 2026.
Chicago "Akinul Islam Jony. Analysis of Multiple String Pattern Matching Algorithms ." Akinul Islam Jony. 2025-11-10. https://en.wikipedia.org/w/index.php?oldid=1321675524.
APA Akinul Islam Jony. (2025). Akinul Islam Jony. Analysis of Multiple String Pattern Matching Algorithms . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1321675524
Cite this article
MLA
"Commentz-Walter algorithm." encyclopegia.org, 2025, https://encyclopegia.org/wiki/commentz-walter-algorithm. Accessed 24 November 2026.
Chicago
"Commentz-Walter algorithm." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/commentz-walter-algorithm.
APA
encyclopegia.org. (2025). Commentz-Walter algorithm. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/commentz-walter-algorithm
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON