Knuth Morris Pratt String Matching Algorithm in Searching for Zakat Information and Social Activities

Algorithms are one of the components that need to be considered in the development of information systems. Determination of the algorithm is adjusted to the purpose of the system to be built. One algorithm that can be used is string matching. The string matching algorithm will play a role in searching for a string consisting of several characters (usually called a pattern). The method used in this research is string matching knuth morris pratt (KMP) which is used to search zakat information and social activities in the search engine system. KMP is a string matching algorithm with good performance. The results showed the performance of string matching using the KMP algorithm with 5 trials of input pattern on zakat information with execution times of 0.03 ms, 0.03 ms, 0.02 ms, 0.02 ms and 0.03 ms. And 5 times the input pattern experiment on social activities with execution time of 0.02 ms, 0.02 ms, 0.03 ms, 0.03 ms and 0.02 ms. Thus the average execution time of the KMP algorithm in string matching is 0.026 ms and 0.024 ms.


Introduction
In the industrial era 4.0, information systems are now growing which have been used in various circles to facilitate user activities and transactions.Algorithms are one of the components that need to be considered in the development of information systems.Determination of the algorithm is adjusted to the purpose of the system to be built.One algorithm that can be used is string matching.String Matching is the process of finding all occurrences of the query, which is then called a pattern into a longer string [1].String matching algorithms (patterns) that have good performance are Knuth Morris Pratt (KMP) and Boyer Moore Algorithm.For string matching using the Brute Force algorithm, every time a pattern mismatch is found with the text, the pattern will be shifted one character to the right.While the KMP algorithm can maintain the information used in performing the number of shifts.The KMP algorithm uses this information to make further shifts, not just one character as in the Brute Force algorithm [2].The optimization of the KMP algorithm will allow an increase in the execution speed of the string matching program [3].
The KMP algorithm has the advantage of finding matches on large files.The KMP algorithm searches for text in order from left to right at the beginning of the text and then shifts the word order to the end of the text [4].The KMP algorithm performs matching with the forward matching performance flow [5].The KMP algorithm basically works through two stages, namely KMP will process the pattern and text first to obtain the basic pattern and index value that will be used for information on calculating the number of shifts.And the second stage of the KMP algorithm will compare the character string and character pattern from left to right, from the beginning to the end of the pattern [6].With the function and purpose of the Knuth Morris Pratt algorithm, the algorithm will be appropriate when used in Riawan and Hariguna / JADS Vol.

16
optimizing search results.Therefore, this research will implement the knuth morris pratt algorithm in website-based software engineering for optimizing search results in the study of finding information about zakat and social activities at LAZISMU Baturraden.

Knuth Morris Pratt (KMP) Method/Algorithm
Knuth Morris Pratt Algorithm (KMP) is an algorithm that is used in the search process where a string (in this case is referred to as a pattern) is found in a collection of other strings with a larger size [7].The KMP (Knuth Morris Pratt) algorithm is a type of Exact String Matching Algorithm which is an exact match of strings with the arrangement of characters in the string being matched having the order or number of characters in the same string [8].The KMP algorithm can shift effectively because it does preprocessing on the pattern so that a LPS component (Longest Proper Prefix Which Is Suffix) can be known, which is obtained based on the pattern sought before the main program is run.LPS is utilized for the largest shift that can be made to avoid unnecessary comparisons [9].A match occurs when the characters in the text and the characters in the pattern being compared are the same, while the mismatch is the opposite [10].

Figure. 1. KMP algorithm method 1) LAZISMU Search Engine System Development
At this stage the researchers designed a search engine system that was used as a medium in research [11].The thing to do at this stage is to build a database and display the search engine.
2) Knuth Morris Pratt Algorithm Implementation At this stage, the Knuth Morris Pratt algorithm is implemented as a search engine to obtain accurate and optimal search results [12].

3) Writing KMP Functions on Search Engines
In order for the Knuth Morris Pratt Algorithm to run well, it is necessary to write several functions, namely KMPSearch and preKMP [13].
4) Testing the Knuth Morris Pratt Algorithm on Search Engine Systems At the testing stage, it will be tested regarding the implementation of the Knuth Morris Pratt algorithm in the search system (search engine) [14][15][16][17].At this stage, the performance of the Knuth Morris Pratt algorithm will be known in obtaining optimal and accurate search results.

5) Input Pattern
In the stage of testing the performance of the KMP algorithm, the first step that must be done is to enter a pattern.Where in this system the pattern is a search query entered by the user on the search engine system [18].The input pattern will continue to be performed every time the KMP algorithm is tested [19].

6) Knuth Morris Pratt Algorithm Performance Analysis
After the pattern input process is carried out, an analysis phase will be carried out on the search performance carried out by the KMP algorithm for pattern matching against the text in the database [20].And it can be seen as the result of the performance of the KMP algorithm.

Result
Optimization of search for zakat information and website-based social activities using the Knuth Morris Pratt algorithm.In the process of implementing the Knuth Morris Pratt algorithm for optimizing the search for zakat information and social activities, it consists of several stages, namely analysis, designing a search function system (search engine), implementing the Knuth Morris Pratt algorithm on the system, and testing the Knuth Morris Pratt algorithm on the search engine function in system.

1) LAZISMU Search Engine System Development
Before implementing the Knuth Morris Pratt (KMP) algorithm in optimizing the search for zakat information and social activities, a search engine system is needed which will later become a medium for implementing the KMP algorithm.
2) Knuth Morris Pratt Algorithm Implementation After the design stage of the search engine function system is complete, then enter the implementation stage of the Knuth Morris Pratt algorithm.The KMP algorithm will play a role in the search for zakat information and social activities optimally in the search engine system.Where the search process is carried out by matching the pattern entered by the user with the existing text pattern in the database.

3) Writing KMP Functions on Search Engines
The Knuth Morris Pratt Algorithm consists of several functions to carry out the process of matching and shifting patterns to the text in the database.Some of the functions used in the KMP Algorithm in the implementation of search engines for zakat information are as follows: Riawan and Hariguna / JADS Vol. 3 No. 1 2022 18

Figure. 2. Function preKMP
The preKMP function will determine the shift in the matching process.Where the match will start from the first index in the pattern against the text stored in the database.The mismatch between the pattern position index and the text will be used as information for shifting.The preKMP function has a pattern variable parameter with the declaration that the text index value is 0 and the pattern index value will be filled with the jump variable value when it is indexed 0.
As long as the condition of the text index value is less than the pattern index value count and as long as the pattern index value is greater than -1 and the pattern index is not the same as the text index, information will be obtained regarding the number of shift jumps that will be carried out with the value based on the location of the index value when it occurs.incompatibility.The KMPSearch function will return the last character index of the pattern found in the string.The KMPSearch function performs branching with conditions as long as the pattern index value (j) is less than the enumeration of the number of indexes in the text, then checks through the isset() command on the pattern and jump variables whether they have been set or not, where the isset function will return false if both variables ( pattern and jump) contains null and returns true if both variables (pattern and jump) have been defined.

Function KMPSearch
And as long as the text index value is not the same as the pattern index value, the pattern index value will be filled in by the value of the jump variable and outside of these conditions (the text index matches the pattern index) then the index value i is 0. And the matching continues with iterations on the index values i++ and j++.And if during the condition that the text index value is greater than the number of pattern index counts, then the result variable value is the text index with the number of pattern index counts.

4) Testing the Knuth Morris Pratt Algorithm on Search Engine Systems
After the implementation stage and writing functions on the KMP Algorithm, then the testing stage is carried out on the application of the search engine system.The process of testing the KMP Algorithm is carried out through several steps as follows:

Input Pattern
The first step in the KMP algorithm testing process that must be done is to enter a pattern.Where pattern is a search query entered by the user.Pattern will be used in the process of matching and shifting the existing text in the database.The pattern input process will be carried out during the KMP Algorithm testing process.

Knuth Morris Pratt Algorithm Performance Analysis
In the Knuth Morris Pratt algorithm, the initial process carried out is inputting the pattern, where the pattern in question is the search query desired by the user.Furthermore, the KMP algorithm will initialize the existing pattern, such as the length of the pattern and determine the index of the pattern and text (data in the database).And then shifting and matching will be done from the pattern to the text.

Discussion
In the implementation of the Knuth Morris Pratt Algorithm, it displays the search process by matching a string that has been matched between the inputted pattern and the description field from the information and activity table contained in your typical database.The following are the results of searching for information on zakat and social activities using the KMP algorithm, which can be seen in the following table.Figure 4 shows the performance of the KMP algorithm on the information table seen through the execution time of matching the pattern with the text in the information database.Where the average execution time is 0.026 ms against 99 data.

Figure. 5. KMP Algorithm Performance Diagram on Activities
Figure 5 shows the performance of the KMP algorithm on the activity table as seen through the execution time of matching the pattern with the text in the activity database.Where the average execution time is 0.024 ms for 8 data.

Conclusion
Based on the results of the analysis and discussion that has been carried out in the implementation of the Knuth Morris Pratt (KMP) Algorithm on search engines for zakat information and social activities, the following conclusions can be drawn: The implementation of the Knuth Morris Pratt Algorithm (KMP) on search engines has good and fast performance in the pattern matching process with text in the database and the Knuth Morris Pratt Algorithm (KMP) will display search results in the form of data that has the same word as the pattern and data containing the word like the characters in the pattern.The Knuth Morris Pratt (KMP) algorithm has the right search results according to the search pattern entered by the user.The search results are text that has the same word as pattern and text that contains words like pattern.The Knuth Morris Pratt (KMP) algorithm has a good performance with the performance of match execution time and search results on the information table an average of 0.026 ms

Table .
From table3.2KMPExecutionPerformance on Zakat Information, it can be seen that the average execution time of the KMP algorithm is 0.026 ms with the amount of text data in the information table database as many as 99 data which are matched according to the pattern.From table3.3KMPExecution Performance on Social Activities, it can be seen that the average execution time of the KMP algorithm is 0.024 ms with the amount of text data in the activity table database as many as 8 data which are matched according to the pattern entered by the user.Thus the results of the search performance of the KMP algorithm function shown by the table with the amount of zakat information data in the database as much as 99 and data on social activities in the database as much as 8 can be presented in the form of a bar chart of the performance of the KMP algorithm as follows: Riawan and Hariguna / JADS Vol. 3 No. 1 2022 Vol. 3, No. 1, January 2022, pp.15-23 ISSN 2723-6471 21 Figure.4. KMP Algorithm Performance Diagram on Information