Evaluation of the Boyer-Moore and Knuth-Morris-Pratt String-Searching
2025 (English)Independent thesis Basic level (professional degree), 180 HE credits
Student thesis
Abstract [en]
The utilization of string searching algorithms holds significant importance within the
field of computer science, including applications in diverse areas such as text pro-
cessing and data analysis. With the advancement of technology, we strive to opti-
mize our search methods for text, whether it is for words, or phrases. Therefore,
the choice of algorithm used to search for a specific string becomes crucial in achiev-
ing the fastest possible results. While many studies have compared string searching
algorithms, limited work has explored how various factors influence their perfor-
mance, particularly in terms of execution time. Accordingly, this work aims to in-
vestigate and evaluate the performance of commonly used string searching algo-
rithms, namely Boyer-Moore, and Knuth-Morris-Pratt, under varying conditions
such as text size, pattern length, RAM, CPU, and choice of compiler. The work in-
volves also a comparative analysis of their performance using the java programming
language with two different IDEs compilers, namely the NetBeans JDK and ECJ
compiler as well as different RAM and CPU configurations. To determine the im-
pact of these factors on the efficiency of the two algorithms, we use factorial analy-
sis, which enables us to assess the relative importance of each factor and identify
their interactions. This work bridges the gap in existing work by investigating how
these factors impact the execution time of string searching algorithms. The analysis
provides valuable insights into the strength and limitations of different algorithms,
offering guidance for optimizing their use and contributing to the development of
more efficient solutions for string searching tasks. In summary, the findings indicate
that the text size and compiler choice have a significant influence on the execution
times of the Boyer-Moore (BM) and Knuth-Morris-Pratt (KMP), algorithms, with
text size having the greatest impact on the execution time.
Abstract [sv]
Användning av strängsökningsalgoritmer har stor betydelse inom datavetenskapen
och tillämpas inom olika områden som textbehandling och dataanalys. Med den tek-
nologiska utvecklingen strävar vi efter att optimera våra sökmetoder för text, oav-
sett om det gäller ord eller fraser. Därför blir valet av algoritm för att söka efter en
specifik sträng avgörande för att uppnå snabbast möjliga resultat. Trotts att ett flertal
studier har genomfört jämförelser av strängsökningsalgoritmer, är det relativt få
undersökningar som har fokuserat på att analysera hur olika faktorer inverkar på de-
ras prestanda, särskilt med avseende på exekveringstid. Följaktligen var syftet med
detta arbete att undersöka och utvärdera prestanda hos två vanliga algoritmer för
strängsökning, Boyer-Moore (BM) och Knuth-Morris-Pratt (KMP), under varie-
rande förhållanden såsom textstorlek, mönsterlängd, tillgänglig RAM, CPU, och val
av kompilator. För att utföra studien genomfördes en jämförande analys av deras
prestanda genom att implementera algoritmerna i programmeringsspråket Java och
använda två olika kompilatorer, nämligen NetBeans JDK och Eclipse kompilator för
java (ECJ). För att bestämma den optimala kombinationen av faktorer användes fak-
toranalys, som möjliggjorde bedömning av den relativa betydelsen av varje faktor
samt identifiering av deras interaktioner. Detta arbete överbygger gapet i befintlig
forskning genom att undersöka hur dessa faktorer påverkar exekveringstiden för
strängsökningsalgoritmer. Analysen ger värdefulla insikter om styrkan och begräns-
ningarna hos olika algoritmer, ger vägledning för att optimera deras användning och
bidrar till utvecklingen av mer effektiva lösningar för strängsökningsuppgifter. Sam-
manfattningsvis antyder resultaten att både textstorleken och valet av kompilator har
en betydande inverkan på exekveringstiden för BM- och KMP-algoritmerna, där
textstorleken har den största inverkan på exekveringstiden.
Place, publisher, year, edition, pages
2025. , p. 29
Keywords [en]
String searching algorithm, Boyer-Moore, Knuth-Morris-Pratt, String matching, Factorial analysis
National Category
Engineering and Technology
Identifiers
URN: urn:nbn:se:hig:diva-46653OAI: oai:DiVA.org:hig-46653DiVA, id: diva2:1946712
Subject / course
Computer science
Educational program
Högskoleingenjör
Presentation
, Gävle (Swedish)
Supervisors
Examiners
2025-04-282025-03-232025-04-28Bibliographically approved