English

Branch Prediction Analysis of Morris-Pratt and Knuth-Morris-Pratt Algorithms

Data Structures and Algorithms 2025-03-19 v1

Abstract

We analyze the classical Morris-Pratt and Knuth-Morris-Pratt pattern matching algorithms through the lens of computer architecture, investigating the impact of incorporating a simple branch prediction mechanism into the model of computation. Assuming a fixed pattern and a random text, we derive precise estimates of the number of mispredictions these algorithms produce using local predictors. Our approach is based on automata theory and Markov chains, providing a foundation for the theoretical analysis of other text algorithms and more advanced branch prediction strategies.

Keywords

Cite

@article{arxiv.2503.13694,
  title  = {Branch Prediction Analysis of Morris-Pratt and Knuth-Morris-Pratt Algorithms},
  author = {Cyril Nicaud and Carine Pivoteau and Stéphane Vialette},
  journal= {arXiv preprint arXiv:2503.13694},
  year   = {2025}
}

Comments

22 pages, 15 figures