<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">JSEA</journal-id><journal-title-group><journal-title>Journal of Software Engineering and Applications</journal-title></journal-title-group><issn pub-type="epub">1945-3116</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/jsea.2016.98026</article-id><article-id pub-id-type="publisher-id">JSEA-69574</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Computer Science&amp;Communications</subject></subj-group></article-categories><title-group><article-title>
 
 
  A Fast Pattern Matching Algorithm Using Changing Consecutive Characters
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Amjad</surname><given-names>Hudaib</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Dima</surname><given-names>Suleiman</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Arafat</surname><given-names>Awajan</given-names></name><xref ref-type="aff" rid="aff2"><sup>2</sup></xref></contrib></contrib-group><aff id="aff2"><addr-line>Department of Computer Science, King Hussein Faculty of Computer Sciences, Princess Sumaya University for Technology, Amman, Jordan</addr-line></aff><aff id="aff1"><addr-line>Department of Computer Information Systems, King Abdullah II for Information Technology, The University of Jorda, Amman, Jordan</addr-line></aff><pub-date pub-type="epub"><day>08</day><month>08</month><year>2016</year></pub-date><volume>09</volume><issue>08</issue><fpage>399</fpage><lpage>411</lpage><history><date date-type="received"><day>20</day>	<month>June</month>	<year>2016</year></date><date date-type="rev-recd"><day>accepted</day>	<month>5</month>	<year>August</year>	</date><date date-type="accepted"><day>8</day>	<month>August</month>	<year>2016</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  Pattern matching is a very important algorithm used in many applications such as search engine and DNA analysis. They are aiming to find a pattern in a text. This paper proposes a Pattern Matching Algorithm Using Changing Consecutive Characters (PMCCC) to make the searching pro- cess of the algorithm faster. PMCCC enhances the shift process that determines how the pattern moves in case of the occurrence of the mismatch between the pattern and the text. It enhances the Berry Ravindran (BR) shift function by using m consecutive characters where m is the pattern length. The formal basis and the algorithms are presented. The experimental results show that PMCCC made enhancements in searching process by reducing the number of comparisons and the number of attempts. Comparing the results of PMCCC with other related algorithms has shown significant enhancements in average number of comparisons and average number of attempts.
 
</p></abstract><kwd-group><kwd>Pattern</kwd><kwd> Pattern Matching Algorithms</kwd><kwd> String Matching</kwd><kwd> Berry Ravindran</kwd><kwd> EBR</kwd><kwd> RS-A</kwd><kwd> Fast Pattern Matching Algorithms</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Pattern matching is considered a very important algorithm in various applications such as search engine and DNA analysis [<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] - [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] .</p><p>The main purpose of pattern matching algorithms is to find a pattern (which is relatively small) in a text (which is very relatively large). They are aiming to enhance the search process and make it faster. This can be done either by decreasing the number of comparisons, attempts or both. Some algorithms made enhancements on searching process and the way comparisons are made between the text and the pattern [<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] - [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] , others made enhancements on the preprocessing phase [<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] - [<xref ref-type="bibr" rid="scirp.69574-ref15">15</xref>] which used to determine the amount of shift in case a mismatch happened between the pattern and the text.</p><p>In some algorithms, comparisons occur between the text and the pattern from only one side of the text either the left side [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] or the right one [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] by aligning one pattern with the text. Other algorithms use two sliding windows to make comparisons by using two patterns, one pattern aligned with the text from left side of the text, and the second pattern aligned with the text from the right side, comparisons occur in parallel [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref11">11</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref16">16</xref>] .</p><p>Another type of enhancements is made on the shift values. The shift value is the amount of shift that the pattern will move in case of a mismatch between the text and the pattern occurs. This enhancement is very important since it affects the efficiency of the searching process. Most of algorithms determine the shift value according to the number of consecutive characters on the text after aligning the pattern with the text. Some algorithms take one consecutive character [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref17">17</xref>] some take two [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref16">16</xref>] others use three and few use four [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref9">9</xref>] .</p><p>This paper proposes a new Pattern Matching algorithm Using Changing Consecutive Characters (PMCCC) to make the searching process of the algorithm faster. PMCCC made enhancements on the shifting values, which maximize the amount of shift that the pattern will move once a mismatch between the text and the pattern occurs. The new algorithm uses only one sliding window so the pattern will be aligned with text from the left side. The formal basis of the algorithm, algorithm steps and analysis is presented. Comparisons are made with existing algorithms such as BR [<xref ref-type="bibr" rid="scirp.69574-ref12">12</xref>] , EBR [<xref ref-type="bibr" rid="scirp.69574-ref11">11</xref>] and RS-A [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] . The results of the comparisons show that the new algorithm is better than the other algorithms in terms of comparisons and number of attempts.</p><p>The reminder of this paper is organized as follows: Section 2 presents the related work. Section 3 describes PMCCC algorithm and analyzes its performance. Section 4 presents a working example to show how the algorithm works. Section 5 shows the experiment and the comparisons with other algorithms. Finally, Section 6 covers the conclusions and future work.</p></sec><sec id="s2"><title>2. Related Works</title><p>Pattern matching is one of the main topics in research since it is very important and can be used in different applications [<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref18">18</xref>] - [<xref ref-type="bibr" rid="scirp.69574-ref22">22</xref>] .</p><p>Enhancements have been made to make the searching process faster either by using different technique for the search process itself or increasing the shift value that the pattern must move in case there is a mismatch between the pattern and the text [<xref ref-type="bibr" rid="scirp.69574-ref10">10</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref15">15</xref>] . Other enhancements were performed to reduce the memory used to deal with the shift values in preprocessing phase.</p><p>Boyer Moore [<xref ref-type="bibr" rid="scirp.69574-ref17">17</xref>] made enhancement in a searching process, if a mismatch occurs between the text and the pattern after aligning the pattern with the text the pattern will be shifted, the amount of shift is determined by aligning the pattern with the text and taking one character in the text immediately to the right of the pattern if the pattern already aligned with left side of the text.</p><p>Berry-Ravindran (BR) [<xref ref-type="bibr" rid="scirp.69574-ref12">12</xref>] made enhancement on Boyer Moore such that instead of taking one character to determine the shift value, BR takes two consecutive characters which makes the value of the shift greater and then the searching process faster.</p><p>Shift technique used in Berry-Ravindran algorithm (BR) [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] form basis for many algorithms to determine the amount of shift in case a mismatch occurs between the text and the pattern. Some algorithms used the same shift technique used in BR by using two consecutive characters but made enhancement in a searching process such as Two Sliding Windows algorithm [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] and Enhanced Two Sliding Windows algorithm [<xref ref-type="bibr" rid="scirp.69574-ref16">16</xref>] . Others made enhancement on number of characters used for shift value, some used three characters as in Enhanced Berry Ravindran [<xref ref-type="bibr" rid="scirp.69574-ref11">11</xref>] and others used four characters such as RS-A [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] and ERS-A [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] .</p><p>Two Sliding Windows algorithm (TSW) [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] used two sliding windows pattern to scan the text from the left and right side at the same time. TSW uses two windows the left window aligned with the text from the left and the right window aligned with the text from the right, the comparisons between the text and the pattern of both sides occurs at the same time. In case a mismatch occurs, the two windows will be shifted, the right window will be shifted to left and the left window will be shifted to right. The amount of shift in the two cases was determined according to BR [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] shift value by taking two consecutive characters.</p><p>Enhanced Two Sliding Window algorithm (ETSW) [<xref ref-type="bibr" rid="scirp.69574-ref16">16</xref>] made enhancements on TSW. ETSW used the same searching technique used in TSW; it also used two windows to scan the text from both sides at the same time, in addition it used the same shift function used in BR and TSW by using two consecutive characters. The main difference between ETSW and TSW is that ETSW made comparisons between the text and the pattern from both sides of the pattern in parallel in this case number of comparisons between the text and the pattern will be minimized. The complexity of best case, worst case and preprocessing time are O(m/2), O(((n/2 − m/2 + 1))(m/2, O(2(m − 1)) respectively.</p><p>To determine the amount of shift instead of using two consecutive characters, in case a mismatch occurs between the text and the pattern as in TSW, Enhanced Berry Ravindran (EBR) [<xref ref-type="bibr" rid="scirp.69574-ref11">11</xref>] used three characters. EBR also used two sliding windows to scan the text from both sides simultaneously.</p><p>ERS-A [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] algorithm made enhancements on RS-A [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] . RS-A algorithms used four consecutive characters immediately after the aligning the text with the pattern to determine the amount of shift that the pattern will move in case a mismatch occurs between the text and the pattern. RS-A searches the text from the right side only. On the other hand ERS-A uses four consecutive character and scans the text from the left and right side at the same time. As in TSW, ERS-A used two sliding windows aligned with the text, the left window aligned with the text from the left and the right window aligned with the text from right, in case a mismatch occurs the two windows will be shifted to the opposite side.</p><p>Enhancing ERS-A algorithm for pattern matching EERS-A [<xref ref-type="bibr" rid="scirp.69574-ref9">9</xref>] used the same technique used in ETSW [<xref ref-type="bibr" rid="scirp.69574-ref16">16</xref>] . Both of them made comparisons between the text and the pattern from both sides of the pattern, they also used two sliding windows to scan the text. But while ETSW using BR shift function, EERS-A uses RS-A shift to determine the amount of shift which depends on using four consecutive characters.</p><p>Four sliding windows pattern matching algorithm (FSW) [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] used four consecutive characters to determine the shift value as in RS-A, ERS-A and EERS-A. FSW used four sliding windows. The text was partitioned into two parts, each part scanned by using two windows, one aligned with the left side of the part and the other with the right side of the part.</p><p>A Performance Study of the Running Times of well-known Pattern Matching Algorithms for Signature-based Intrusion Detection Systems [<xref ref-type="bibr" rid="scirp.69574-ref20">20</xref>] was done and comparisons between different algorithms using multiple sliding windows approach were made.</p><p>PMCCC uses only one pattern window to search for a pattern p in text t from the left side of the text. In case a mismatch occurs between the pattern and the text the pattern will be shifted to right according to the shift value. The shift value is determined according to the pattern length m. Instead of taking two consecutive characters to determine the amount of shift as in TSW, three characters as in EBR or four characters in EERS-A, the new algorithm takes m (pattern length) consecutive characters immediately of the text after aligning the pattern with the left side of the text. Additional two algorithms shift 5 and shift 6 are developed to make comparisons. These two algorithms use one window to scan the text from the left side. They use five and six consecutive characters respectively to determine the amount of shift.</p><p>Comparing the results of the proposed algorithm with those of Br, EBR and RS-A has shown significant enhancements in average number of attempts and comparisons. The new algorithm makes the searching process faster and more efficient.</p></sec><sec id="s3"><title>3. Description of the (PMCCC) Algorithm</title><p>PMCCC enhanced the searching process by increasing the amount of shift that occurs every time there is a mismatch between the text and the pattern. PMCCC depends on using m consecutive characters of the text immediately after aligning the text with the pattern, where m is the same as the pattern length. PMCCC algorithm determines the number of the consecutive characters according to the length of pattern.</p><p>The main difference between BR [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] , EBR [<xref ref-type="bibr" rid="scirp.69574-ref11">11</xref>] , RS-A [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] and PMCCC is that each one of the previous algorithms used a fixed length number of consecutive characters after the text to determine the amount of shift, BR uses two consecutive characters, EBR uses three and RS-A uses four.</p><sec id="s3_1"><title>3.1. Pre-Processing Phase</title><p>PMCCC calculates the value of the shift using m consecutive text characters<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-9302280x6.png" xlink:type="simple"/></inline-formula>, where m is the pattern length which are aligned immediately to the right of text.</p><p>Initially, m consecutive characters in the text have the indexes <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-9302280x7.png" xlink:type="simple"/></inline-formula> for<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-9302280x8.png" xlink:type="simple"/></inline-formula>. After a mismatch occurs between the text and the pattern, the pattern will be shifted to the right according to the shift value, which will be calculated by PMCCC algorithm (see <xref ref-type="fig" rid="fig1">Figure 1</xref>).</p><p>After shifting m consecutive characters immediately to right of the text will be (leftindex + 1), (leftindex + 2), (leftindex + 3), …., (leftindex + m) for<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/1-9302280x9.png" xlink:type="simple"/></inline-formula>. <xref ref-type="fig" rid="fig1">Figure 1</xref> shows the code of PMCCC algorithm where the shifting process is presented.</p><p>The main idea of the proposed algorithm is to use shift function used in BR [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] , Berry Ravindran used two consecutive characters in the text that follow the pattern window to determine the shift value. It depends on using equation (1) to determine the amount of shift, x<sub>1</sub> and x<sub>2</sub> are the two consecutive characters, p is the pattern, and m the pattern length.</p><disp-formula id="scirp.69574-formula52"><label>(1)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-9302280x10.png"  xlink:type="simple"/></disp-formula><p>Other algorithms also used BR shift function such as EBR [<xref ref-type="bibr" rid="scirp.69574-ref11">11</xref>] and RS-A [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] , but instead of using two characters they used three and four characters respectively. The shifting techniques used in EBR and RS-A depended on equation (2) and equation (3) respectively.</p><disp-formula id="scirp.69574-formula53"><label>(2)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-9302280x11.png"  xlink:type="simple"/></disp-formula><fig id="fig1"  position="float"><label><xref ref-type="fig" rid="fig1">Figure 1</xref></label><caption><title> PMCCC algorithm-shifting process</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-9302280x12.png"/></fig><disp-formula id="scirp.69574-formula54"><label>(3)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-9302280x13.png"  xlink:type="simple"/></disp-formula><p>In order to make a good comparisons, we implemented two new algorithms and called them shift 5 and shift 6. Shift 5 and shift 6 also used Berry Ravindran shift but they used 5 and 6 characters respectively to determine the amount of shift. The shifting process of algorithm shift 5 depends on equation (4) and the shifting process of shift 6 depends on equation (5).</p><disp-formula id="scirp.69574-formula55"><label>(4)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-9302280x14.png"  xlink:type="simple"/></disp-formula><disp-formula id="scirp.69574-formula56"><label>(5)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-9302280x15.png"  xlink:type="simple"/></disp-formula><p>PMCCC algorithm used m characters, where m is the pattern length, to determine the amount of shift and depends on equation (6).</p><p><xref ref-type="fig" rid="fig2">Figure 2</xref> presents how PMCCC algorithm calculates the shift value based on equation (6).</p><fig id="fig2"  position="float"><label><xref ref-type="fig" rid="fig2">Figure 2</xref></label><caption><title> The shifting process of PMCCC algorithm</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-9302280x16.png"/></fig><disp-formula id="scirp.69574-formula57"><label>(6)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/1-9302280x17.png"  xlink:type="simple"/></disp-formula></sec><sec id="s3_2"><title>3.2. Searching Phase</title><p>PMCCC algorithm starts the searching from the left side of the pattern using one window, in case of a mismatch between the text and the window; the window will be shifted to the right according to the shift value in equation (6).</p><p>One pointer (leftindex) in the text and one pointer in the pattern (L) will be used to make comparison between the text and the pattern. The first character of the pattern and the corresponding text character (leftindex) will be compared. If a match occurs the leftindex and L will be incremented by one and if a mismatch occurs the leftindex will be incremented by the shift value and L index value will be zero.</p><p>One pointer (leftindex) in the text and one pointer in the pattern (L) will be used to make comparison between the text and the pattern. The first character of the pattern and the corresponding text character (leftindex) will be compared. If a match occurs the leftindex and L will be incremented by one and if a mismatch occurs the leftindex will be incremented by the shift value and L index value will be zero.</p></sec><sec id="s3_3"><title>3.3. Analysis</title><p>Lemma 1: The time complexity in worst case is O(((n − m + 1))(m)).</p><p>Proof: The worst case occurs when a match between the pattern and text occurs in all characters (i.e. The shift value is equal to one), until we reach the last character of the pattern and a mismatch between the pattern and text occurs. This case is reputed until we reach the index (n − (m + 1)) of the text.</p><p>Lemma 2: The time complexity in best case is O(m).</p><p>Proof: The best case occurs when a match occurs between the pattern and the text in the leftmost of the text.</p><p>Lemma 3: The time complexity in average case is O(n/(2*m)).</p><p>Proof: The average case occurs when the m consecutive characters immediately to the right of the text after aligning it with the pattern are not found in the pattern. In this case, time complexity is O(n/(2*m)) and the shift value will be (2*m).</p></sec></sec><sec id="s4"><title>4. Working Example</title><p>In this section, we will give an example to explain the new algorithm.</p><p>Given a text T with n = 50.</p><p>T = “ABECABACBAFECABAEEBEBEABACBEECABACCCBAEEBABEBEBABA”, with index from 0 to 49.</p><p>And a pattern P with m = 9:</p><p>P = “ABACCCBAE”, with index from 0 to 9.</p><p>Pre-processing phase</p><p>Initially, shift value = 2*m = 18.</p><p>Searching phase</p><p>The searching process for the pattern p is explained through the following steps:</p><p>First attempt:</p><p>In the first attempt (<xref ref-type="fig" rid="fig3">Figure 3</xref>(a)), we align the pattern window with the text from the left, a comparison is made between and first character in the pattern (P [<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = A) and the first character of the text (T [<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = A). Since the two characters are the same, another comparison is made between the second character in the pattern (P [<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] = B) and the second character of the text (T [<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] = B), and again a match occurs. Comparisons continue until either a complete match occurs or a mismatch occurs. In this example a mismatch occurs between the third character of the pattern (P [<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] = A), and of the text (T [<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] = E), therefore we take 9 consecutive characters of the text at indexes: 9, 10, 11, 12, 13, 14, 15, 16, 17 which are A, F, E, C, A, B, A, E, E respectively.</p><p>To determine the shift value we have to make the following comparison according to equation (6) as in <xref ref-type="table" rid="table1">Table 1</xref>. Then the pattern will be shifted to right 13 steps.</p><p>Second attempt:</p><p>In the second attempt, after shifting the pattern 13 steps to the right (<xref ref-type="fig" rid="fig3">Figure 3</xref>(b)), the first character of the pattern is found and is aligned with the text character at index 13. After making comparison between the text and the pattern a mismatch occurs between the text character at index 16 (character E) and the fourth index in the pattern (character C). To determine the shift value we take 9 consecutive characters at indexes: 22, 23, 24, 25, 26, 27, 28, 29, 30 which are A, B, A, C, B, E, E, C, A respectively. So that the pattern must be shifted using equation 6 as shown in <xref ref-type="table" rid="table2">Table 2</xref>. Again to determine amount of shift we apply equation (6) and shown in <xref ref-type="table" rid="table2">Table 2</xref>. Then the pattern will be shifted to right 11 steps.</p><p>Third attempt:</p><p>In the third attempt, a mismatch occurs between text character at index 25 (character C) and the second pattern text (character B), (see <xref ref-type="fig" rid="fig3">Figure 3</xref>(c)). The nine consecutive characters at indexes: 33, 34, 35, 36, 37, 38, 39, 40, 41, which are C, C, C, B, A, E, E, B, A, respectively.</p><fig id="fig3"  position="float"><label><xref ref-type="fig" rid="fig3">Figure 3</xref></label><caption><title> Working example</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-9302280x18.png"/></fig><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Determine the shift value for the first attempt</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Shift value</th><th align="center" valign="middle" >Comparisons</th></tr></thead><tr><td align="center" valign="middle" >1</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = A?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >2</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AF?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >3</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AFE?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >4</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>][<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AFEC?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >if p [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AFECA?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AFECAB?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AFECABA?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AFECABAE?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AFECABAEE?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = F?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = E?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = C, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >13</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = A?, Yes stop the shift value will be 13</td></tr></tbody></table></table-wrap><table-wrap id="table2" ><label><xref ref-type="table" rid="table2">Table 2</xref></label><caption><title> Determine the shift value for the second attempt</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Shift value</th><th align="center" valign="middle" >Comparisons</th></tr></thead><tr><td align="center" valign="middle" >1</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = A?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >2</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = AB?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >3</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = ABA?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >4</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = ABAC?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = ABACB?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = ABACBE?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = ABACBEE?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = ABACBEEC?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = ABACBEEECA?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = B?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref0">0</xref>] = A?, Yes stop the shift value will be 11</td></tr></tbody></table></table-wrap><p>Now, to determine amount of shift we apply equation (6) and shown in <xref ref-type="table" rid="table3">Table 3</xref>, so that, the pattern will be shifted to the right 6 steps.</p><p>Fourth attempt:</p><p>We align the first character of the pattern (character A) with text character at index 30 (character A). A complete match between the text and pattern occurs at index 30, (see <xref ref-type="fig" rid="fig3">Figure 3</xref>(d)).</p></sec><sec id="s5"><title>5. Experimental Results and Discussion</title><p>Multiple experiments have been done to make comparisons between PMCCC and other algorithms. In addition to implementing the PMCCC, we implemented two other algorithms shift 5 and shift 6 to make good comparisons. Shift 5 and shift 6 algorithms used the same shift functions used in BR [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] , but instead of taking two consecutive characters to determine the shift value, shift 5 and shift 6 algorithms used 5 and 6 consecutive characters respectively. Also we used the well-known algorithms to make comparisons, which are BR [<xref ref-type="bibr" rid="scirp.69574-ref13">13</xref>] , EBR [<xref ref-type="bibr" rid="scirp.69574-ref11">11</xref>] , RS-A [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] which uses 2, 3, 4 consecutive characters respectively to determine the shift value. But since EBR used two sliding windows we implement it using only the left side equations to determine the amount of shift.</p><table-wrap id="table3" ><label><xref ref-type="table" rid="table3">Table 3</xref></label><caption><title> Determine the shift value for the third attempt</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Shift value</th><th align="center" valign="middle" >Comparisons</th></tr></thead><tr><td align="center" valign="middle" >1</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = C?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >2</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = CC?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >3</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = CCC?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >4</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = CCCB?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = CCCBA?, Yes stop. No, continue</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >if p[<xref ref-type="bibr" rid="scirp.69574-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref4">4</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref6">6</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref7">7</xref>] [<xref ref-type="bibr" rid="scirp.69574-ref8">8</xref>] = CCCBAE?, Yes stop the shift value will be 6</td></tr></tbody></table></table-wrap><table-wrap id="table4" ><label><xref ref-type="table" rid="table4">Table 4</xref></label><caption><title> The average number of comparisons for patterns with different lengths</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Pattern length</th><th align="center" valign="middle" >Number of words</th><th align="center" valign="middle" >BR</th><th align="center" valign="middle" >EBR</th><th align="center" valign="middle" >RS-A</th><th align="center" valign="middle" >Shift 5</th><th align="center" valign="middle" >Shift 6</th><th align="center" valign="middle" >PMCCC</th></tr></thead><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >1988</td><td align="center" valign="middle" >13345</td><td align="center" valign="middle" >11749</td><td align="center" valign="middle" >10638</td><td align="center" valign="middle" >9783</td><td align="center" valign="middle" >9100</td><td align="center" valign="middle" >8056</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >1167</td><td align="center" valign="middle" >14807</td><td align="center" valign="middle" >13092</td><td align="center" valign="middle" >11922</td><td align="center" valign="middle" >11033</td><td align="center" valign="middle" >10320</td><td align="center" valign="middle" >9217</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >681</td><td align="center" valign="middle" >15892</td><td align="center" valign="middle" >14095</td><td align="center" valign="middle" >12911</td><td align="center" valign="middle" >12004</td><td align="center" valign="middle" >11273</td><td align="center" valign="middle" >10141</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >382</td><td align="center" valign="middle" >15799</td><td align="center" valign="middle" >14070</td><td align="center" valign="middle" >12927</td><td align="center" valign="middle" >12064</td><td align="center" valign="middle" >11362</td><td align="center" valign="middle" >10289</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >191</td><td align="center" valign="middle" >14243</td><td align="center" valign="middle" >12675</td><td align="center" valign="middle" >11672</td><td align="center" valign="middle" >10910</td><td align="center" valign="middle" >10298</td><td align="center" valign="middle" >9367</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >69</td><td align="center" valign="middle" >10923</td><td align="center" valign="middle" >9774</td><td align="center" valign="middle" >9030</td><td align="center" valign="middle" >8508</td><td align="center" valign="middle" >8074</td><td align="center" valign="middle" >7401</td></tr><tr><td align="center" valign="middle" >13</td><td align="center" valign="middle" >55</td><td align="center" valign="middle" >11370</td><td align="center" valign="middle" >10191</td><td align="center" valign="middle" >9422</td><td align="center" valign="middle" >8895</td><td align="center" valign="middle" >8466</td><td align="center" valign="middle" >7786</td></tr><tr><td align="center" valign="middle" >14</td><td align="center" valign="middle" >139</td><td align="center" valign="middle" >21673</td><td align="center" valign="middle" >19255</td><td align="center" valign="middle" >17845</td><td align="center" valign="middle" >16843</td><td align="center" valign="middle" >16008</td><td align="center" valign="middle" >14734</td></tr><tr><td align="center" valign="middle" >15</td><td align="center" valign="middle" >32</td><td align="center" valign="middle" >22384</td><td align="center" valign="middle" >19747</td><td align="center" valign="middle" >18318</td><td align="center" valign="middle" >17261</td><td align="center" valign="middle" >16435</td><td align="center" valign="middle" >15107</td></tr><tr><td align="center" valign="middle" >16</td><td align="center" valign="middle" >10</td><td align="center" valign="middle" >28644</td><td align="center" valign="middle" >25452</td><td align="center" valign="middle" >23531</td><td align="center" valign="middle" >22163</td><td align="center" valign="middle" >21080</td><td align="center" valign="middle" >19381</td></tr><tr><td align="center" valign="middle" >17</td><td align="center" valign="middle" >3</td><td align="center" valign="middle" >28148</td><td align="center" valign="middle" >25169</td><td align="center" valign="middle" >23119</td><td align="center" valign="middle" >21922</td><td align="center" valign="middle" >20895</td><td align="center" valign="middle" >19252</td></tr></tbody></table></table-wrap><fig id="fig4"  position="float"><label><xref ref-type="fig" rid="fig4">Figure 4</xref></label><caption><title> The average number of comparisons of BR, EBR, RS-A, Shift 5, Shift 6 and PMCCC Algorithms</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-9302280x19.png"/></fig><table-wrap id="table5" ><label><xref ref-type="table" rid="table5">Table 5</xref></label><caption><title> The average number of attempts for patterns with different lengths</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Pattern length</th><th align="center" valign="middle" >Number of words</th><th align="center" valign="middle" >BR</th><th align="center" valign="middle" >EBR</th><th align="center" valign="middle" >RS-A</th><th align="center" valign="middle" >Shift 5</th><th align="center" valign="middle" >Shift 6</th><th align="center" valign="middle" >PMCCC</th></tr></thead><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >1988</td><td align="center" valign="middle" >11953</td><td align="center" valign="middle" >10505</td><td align="center" valign="middle" >9512</td><td align="center" valign="middle" >8749</td><td align="center" valign="middle" >8139</td><td align="center" valign="middle" >7203</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >1167</td><td align="center" valign="middle" >13256</td><td align="center" valign="middle" >11704</td><td align="center" valign="middle" >10660</td><td align="center" valign="middle" >9866</td><td align="center" valign="middle" >9226</td><td align="center" valign="middle" >8241</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >681</td><td align="center" valign="middle" >14149</td><td align="center" valign="middle" >12532</td><td align="center" valign="middle" >11477</td><td align="center" valign="middle" >10673</td><td align="center" valign="middle" >10024</td><td align="center" valign="middle" >9019</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >382</td><td align="center" valign="middle" >14127</td><td align="center" valign="middle" >12567</td><td align="center" valign="middle" >11543</td><td align="center" valign="middle" >10774</td><td align="center" valign="middle" >10148</td><td align="center" valign="middle" >9188</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >191</td><td align="center" valign="middle" >12808</td><td align="center" valign="middle" >11378</td><td align="center" valign="middle" >10480</td><td align="center" valign="middle" >9798</td><td align="center" valign="middle" >9252</td><td align="center" valign="middle" >8410</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >69</td><td align="center" valign="middle" >9598</td><td align="center" valign="middle" >8584</td><td align="center" valign="middle" >7927</td><td align="center" valign="middle" >7472</td><td align="center" valign="middle" >7091</td><td align="center" valign="middle" >6507</td></tr><tr><td align="center" valign="middle" >13</td><td align="center" valign="middle" >55</td><td align="center" valign="middle" >10334</td><td align="center" valign="middle" >9250</td><td align="center" valign="middle" >8560</td><td align="center" valign="middle" >8069</td><td align="center" valign="middle" >7677</td><td align="center" valign="middle" >7065</td></tr><tr><td align="center" valign="middle" >14</td><td align="center" valign="middle" >139</td><td align="center" valign="middle" >19548</td><td align="center" valign="middle" >17356</td><td align="center" valign="middle" >16086</td><td align="center" valign="middle" >15172</td><td align="center" valign="middle" >14423</td><td align="center" valign="middle" >13273</td></tr><tr><td align="center" valign="middle" >15</td><td align="center" valign="middle" >32</td><td align="center" valign="middle" >19817</td><td align="center" valign="middle" >17454</td><td align="center" valign="middle" >16176</td><td align="center" valign="middle" >15249</td><td align="center" valign="middle" >14517</td><td align="center" valign="middle" >13362</td></tr><tr><td align="center" valign="middle" >16</td><td align="center" valign="middle" >10</td><td align="center" valign="middle" >26086</td><td align="center" valign="middle" >23176</td><td align="center" valign="middle" >21411</td><td align="center" valign="middle" >20176</td><td align="center" valign="middle" >19194</td><td align="center" valign="middle" >17662</td></tr><tr><td align="center" valign="middle" >17</td><td align="center" valign="middle" >3</td><td align="center" valign="middle" >22554</td><td align="center" valign="middle" >20138</td><td align="center" valign="middle" >18551</td><td align="center" valign="middle" >17570</td><td align="center" valign="middle" >16747</td><td align="center" valign="middle" >15458</td></tr></tbody></table></table-wrap><fig id="fig5"  position="float"><label><xref ref-type="fig" rid="fig5">Figure 5</xref></label><caption><title> The average number of attempts of BR, EBR, RS-A, Shift 5, Shift 6 and PMCCC algorithms</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/1-9302280x20.png"/></fig><p> Dataset:</p><p>All the six algorithms used Book1 from the Calgary corpus to be the text [<xref ref-type="bibr" rid="scirp.69574-ref23">23</xref>] . Book1 consists of 141,274 words (752,149 characters). Patterns of different lengths are also taken randomly from Book1.</p><p><xref ref-type="table" rid="table4">Table 4</xref> shows the results of comparing the algorithms BR, EBR, RS-A, shift 5, shift 6 and PMCCC based on the average number of comparisons using different patterns with different lengths. The pattern length is in the first column and it is from 7 characters to 17 characters. The number of patterns with a certain length is presented in the second column. The results are represented in <xref ref-type="fig" rid="fig4">Figure 4</xref>. <xref ref-type="table" rid="table4">Table 4</xref> and <xref ref-type="fig" rid="fig4">Figure 4</xref> show that PMCCC results are better than all other algorithms results in term of average number of comparisons. For example, <xref ref-type="table" rid="table4">Table 4</xref> shows that for 191 words of length 11, the average number of comparisons is 9367, which is better than all other algorithms. Average number of comparisons for the same pattern length are 14243, 12675, 11672, 10910 and 10298 in BR, EBR, RS-A, shift 5, shift 6 algorithms respectively. The main reason for that is PMCCC always use m consecutive characters to determine the shift value. That means the PMCCC algorithm is faster than the other algorithm in finding pattern.</p><p><xref ref-type="table" rid="table5">Table 5</xref> shows the comparison between PMCCC algorithm and the other algorithms in terms of the average number of attempts using different patterns with different lengths. The results show that PMCCC algorithm needs less number of attempts than the other algorithm. For example, <xref ref-type="table" rid="table5">Table 5</xref> shows for 191 words of length 11, the average number of attempts of PMCCC algorithm is 8410, which is better than the results of all other algorithms. The average number of attempts for the same pattern length are 12808, 11378, 10480, 9798, and 9252 in BR, EBR, RS-A, shift 5, shift 6 algorithms respectively. The main reason for that is PMCCC always use m consecutive characters to determine the shift value. That means the PMCCC algorithm is faster than the other algorithm in finding pattern. <xref ref-type="fig" rid="fig5">Figure 5</xref> represents the results.</p></sec><sec id="s6"><title>6. Conclusion and Future Work</title><p>This paper proposed a new pattern matching algorithm based on Changing Consecutive Characters (PMCCC) to make the searching process of the algorithm faster. PMCCC algorithm uses m consecutive characters where m is the pattern length to determine the shift value in case a mismatch occurs between the text and pattern. This process made the PMCCC faster than many other algorithms that used shift function. Comparisons made between PMCCC and already existing algorithms BR, EBR, RS-A and also comparisons made with new algorithms implemented for the purpose of comparison, are called Shift 5 and Shift 6, respectively. The experimental results show that PMCCC is the faster than other algorithms in terms of number of comparison and attempts.</p></sec><sec id="s7"><title>Cite this paper</title><p>Amjad Hudaib,Dima Suleiman,Arafat Awajan, (2016) A Fast Pattern Matching Algorithm Using Changing Consecutive Characters. Journal of Software Engineering and Applications,09,399-411. doi: 10.4236/jsea.2016.98026</p></sec></body><back><ref-list><title>References</title><ref id="scirp.69574-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Chao, Y. (2012) An Improved BM Pattern Matching Algorithm in Intrusion Detection System. Applied Mechanics and Materials, 148-149, 1145-1148.</mixed-citation></ref><ref id="scirp.69574-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Diwate, R. and Alaspurkar, S. (2013) Study of Different Algorithms for Pattern Matching. International Journal of Advanced Research in Computer Science and Software Engineering, 3, 615-620.</mixed-citation></ref><ref id="scirp.69574-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Bhukya, R. and Somayajulu, D. (2010) An Index Based Forward Backward Multiple Pattern Matching Algorithm. World Academy of Science, Engineering and Technology, 4, 1513-1521.</mixed-citation></ref><ref id="scirp.69574-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Senapati, K.K., Mal, S. and Sahoo, G. (2012) RS-A Fast Pattern Matching Algorithm for Biological Sequences. International Journal of Engineering and Innovative Technology (IJEIT), 1, 116-118.</mixed-citation></ref><ref id="scirp.69574-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Suleiman, D., Hudaib, A., Al-Anani, A., Al-Khalid, R. and Itriq, M. (2013) ERS-A Algorithm for Pattern Matching. Middle East Journal of Scientific Research, 15, 1067-1075.</mixed-citation></ref><ref id="scirp.69574-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Hudaib, A., Al-Khalid, R., Suleiman, D., Itriq, M. and Al-Anani, A. (2008) A Fast Pattern Matching Algorithm with Two Sliding Windows (TSW). Journal of Computer Science, 4, 393-401. http://dx.doi.org/10.3844/jcssp.2008.393.401</mixed-citation></ref><ref id="scirp.69574-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Pendlimarri, D. and Petlu, P.B.B. (2010) Novel Pattern Matching Algorithm for Single Pattern Matching. International Journal on Computer Science and Engineering, 2, 2698-2704.</mixed-citation></ref><ref id="scirp.69574-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Hudaib, A., Al-Kalid, R., Al-Anani, A., Itriq, M. and Suleiman, D. (2015) Four Sliding Windows Pattern Matching Algorithm (FSW). Journal of Software Engineering and Applications, 8, 154-165.  
http://dx.doi.org/10.4236/jsea.2015.83016</mixed-citation></ref><ref id="scirp.69574-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Suleiman, D., Itriq, M., Al-Anani, A., Al-Khalid, R. and Hudaib, A. (2015) Enhancing ERS-A Algorithm for Pattern Matching (EERS-A). Journal of Software Engineering and Applications, 8, 143-153.  
http://dx.doi.org/10.4236/jsea.2015.83015</mixed-citation></ref><ref id="scirp.69574-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Salmela, L., Tarhio, J. and Kalsi, P. (2010) Approximate Boyer-Moore String Matching for Small Alphabets. Algorithmica, 58, 591-609. http://dx.doi.org/10.1007/s00453-009-9286-3</mixed-citation></ref><ref id="scirp.69574-ref11"><label>11</label><mixed-citation publication-type="journal" xlink:type="simple"><name name-style="western"><surname>Suleiman</surname><given-names> D. </given-names></name>,<etal>et al</etal>. (<year>2014</year>)<article-title>Enhanced Berry Ravindran Pattern Matching Algorithm (EBR)</article-title><source> Life Science Journal</source><volume> 11</volume>,<fpage> 395</fpage>-<lpage>402</lpage>.<pub-id pub-id-type="doi"></pub-id></mixed-citation></ref><ref id="scirp.69574-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">Al-Mazroi, A. and Rashid, N. (2011) A Fast Hybrid Algorithm for the Exact String Matching Problem. American Journal of Engineering and Applied Sciences, 4, 102-107. http://dx.doi.org/10.3844/ajeassp.2011.102.107</mixed-citation></ref><ref id="scirp.69574-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Berry, T. and Ravindran, S. (2001) A Fast String Matching Algorithm and Experimental Results. Proceedings of the Prague Stringology Club Workshop ’99, Collaborative Report DC-99-05, Czech Technical University, Prague, 16-26.</mixed-citation></ref><ref id="scirp.69574-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Faro, S. (2009) Efficient Variants of the Backward-Oracle-Matching Algorithm. International Journal of Foundations of Computer Science, 20, 967-984. http://dx.doi.org/10.1142/S0129054109006991</mixed-citation></ref><ref id="scirp.69574-ref15"><label>15</label><mixed-citation publication-type="other" xlink:type="simple">Faro, S. and Külekci, M.O. (2012) Fast Packed String Matching for Short Patterns. arXiv:1209.6449v1 [cs.IR]</mixed-citation></ref><ref id="scirp.69574-ref16"><label>16</label><mixed-citation publication-type="other" xlink:type="simple">Itriq, M., Hudaib, A., Al-Anani, A., Al-Khalid, R. and Suleiman, D. (2012) Enhanced Two Sliding Windows Algorithm for Pattern Matching (ETSW). Journal of American Science, 8, 607-616.</mixed-citation></ref><ref id="scirp.69574-ref17"><label>17</label><mixed-citation publication-type="other" xlink:type="simple">Boyer, R.S. and Moore, J.S. (1977) A Fast String Searching Algorithm. Communications of the Association for Computing Machinery, 20, 762-772. http://dx.doi.org/10.1145/359842.359859</mixed-citation></ref><ref id="scirp.69574-ref18"><label>18</label><mixed-citation publication-type="other" xlink:type="simple">Hlayel, A.A. and Hnaif, A.A. (2014) A New Exact Pattern Matching Algorithm (WEMA). Journal of Applied Science, 14, 193-196. http://dx.doi.org/10.3923/jas.2014.193.196</mixed-citation></ref><ref id="scirp.69574-ref19"><label>19</label><mixed-citation publication-type="other" xlink:type="simple">Hussain, I., Kausar, S., Hussain, L. and Khan, M. (2013) Improved Approach for Exact Pattern Matching (Bidirectional Exact Pattern Matching). IJCSI International Journal of Computer Science Issues, 10, 59-65.</mixed-citation></ref><ref id="scirp.69574-ref20"><label>20</label><mixed-citation publication-type="other" xlink:type="simple">Naik, S.M. and Geethanjali, N. (2015) Performance Study of the Running Times of Well Known Pattern Matching Algorithms for Signature-Based Intrusion Detection Systems. International Journal on Recent and Innovation Trends in Computing and Communication, 3, 4177-4180.</mixed-citation></ref><ref id="scirp.69574-ref21"><label>21</label><mixed-citation publication-type="other" xlink:type="simple">Vangipuram, R.K., Sandeep, S.J. and Reddy, A. (2011) Text Segmentation Based Pattern Search Algorithm. International Journal of Wisdom Based Computing, 1.</mixed-citation></ref><ref id="scirp.69574-ref22"><label>22</label><mixed-citation publication-type="other" xlink:type="simple">Hussain, I., Kazmi, S., Khan, I. and Mehmood, R. (2013) Improved-Bidirectional Exact Pattern Matching. International Journal of Scientific &amp; Engineering Research, 4, 659-663.</mixed-citation></ref><ref id="scirp.69574-ref23"><label>23</label><mixed-citation publication-type="other" xlink:type="simple">Calgary Corpus. ftp://ftp.cpsc.ucalgary.ca/pub/projects/text.compression.corpus</mixed-citation></ref></ref-list></back></article>