<?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.2015.83015</article-id><article-id pub-id-type="publisher-id">JSEA-54867</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>
 
 
  Enhancing ERS-A Algorithm for Pattern Matching (EERS-A)
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>ima</surname><given-names>Suleiman</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Mariam</surname><given-names>Itriq</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Aseel</surname><given-names>Al-Anani</given-names></name><xref ref-type="aff" rid="aff2"><sup>2</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Rola</surname><given-names>Al-Khalid</given-names></name><xref ref-type="aff" rid="aff2"><sup>2</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><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="aff2"><sup>2</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib></contrib-group><aff id="aff2"><addr-line>Department of Computer Information Systems, King Abdullah II School for Information Technology, The University of Jordan, Amman, Jordan</addr-line></aff><aff id="aff1"><addr-line>Department of Business Information Technology, King Abdullah II School for Information Technology, The University of Jordan, Amman, Jordan</addr-line></aff><author-notes><corresp id="cor1">* E-mail:<email>dima.suleiman@ju.edu.jo(IS)</email>;<email>m.itriq@ju.edu.jo(MI)</email>;<email>a.anani@ju.edu.jo(AA)</email>;<email>r.khalid@ju.edu.jo(RA)</email>;<email>ahudaib@ju.edu.jo(AH)</email>;</corresp></author-notes><pub-date pub-type="epub"><day>03</day><month>03</month><year>2015</year></pub-date><volume>08</volume><issue>03</issue><fpage>143</fpage><lpage>153</lpage><history><date date-type="received"><day>25</day>	<month>February</month>	<year>2015</year></date><date date-type="rev-recd"><day>accepted</day>	<month>18</month>	<year>March</year>	</date><date date-type="accepted"><day>20</day>	<month>March</month>	<year>2015</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 topic in computer science. It has been used in various applications such as information retrieval, virus scanning, DNA sequence analysis, data mining, machine learning, network security and pattern recognition. This paper has presented a new pattern matching algorithm—Enhanced ERS-A, which is an improvement over ERS-S algorithm. In ERS-A, two sliding windows are used to scan the text from the left and the right simultaneously. The proposed algorithm also scans the text from the left and the right simultaneously as well as making comparisons with the pattern from both sides simultaneously. The comparisons done between the text and the pattern are done from both sides in parallel. The shift technique used in the Enhanced ERS-A is the four consecutive characters in the text immediately following the pattern window. The experimental results show that the Enhanced ERS-A has enhanced the process of pattern matching by reducing the number of comparisons performed.
 
</p></abstract><kwd-group><kwd>Pattern Matching</kwd><kwd> Enhanced Two Sliding Windows Algorithm</kwd><kwd> RS-A Fast Pattern Matching Algorithm</kwd><kwd> Enhanced RS-A</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Many applications use pattern matching algorithms such as search engines, anti-virus and biological applications such as DNA [<xref ref-type="bibr" rid="scirp.54867-ref1">1</xref>] - [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] .</p><p>Most of the algorithms have been implemented in order to make the searching process faster and more efficient; this can be achieved either by reducing the number of attempts, comparisons or by both. Some of algorithms made enhancements on preprocessing phase [<xref ref-type="bibr" rid="scirp.54867-ref6">6</xref>] - [<xref ref-type="bibr" rid="scirp.54867-ref9">9</xref>] and searching phase [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] - [<xref ref-type="bibr" rid="scirp.54867-ref12">12</xref>] , and others modified the shifting technique [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref9">9</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref13">13</xref>] - [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] used in a case of a mismatch between the pattern and the text.</p><p>Searching process differs from one algorithm to another: some algorithms scan the text from one side only, either from left [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] or from right [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] ; other algorithms use two sliding windows to scan the text from the left and the right sides simultaneously [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] - [<xref ref-type="bibr" rid="scirp.54867-ref13">13</xref>] .</p><p>Some algorithms made modification on the shifting values. The shift value is the amount of shift that the sliding window will move in a case of a mismatch between the text and the window; shift values depend on the number of consecutive characters immediately after the sliding window. Some algorithms use one consecutive character [<xref ref-type="bibr" rid="scirp.54867-ref16">16</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref17">17</xref>] ; others use two [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref12">12</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] and few use three [<xref ref-type="bibr" rid="scirp.54867-ref13">13</xref>] .</p><p>In this paper, we propose a new pattern matching algorithm―Enhanced ERS-A. The algorithm uses two sliding windows such as TSW [<xref ref-type="bibr" rid="scirp.54867-ref12">12</xref>] , ETSW [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] , ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] and EBR [<xref ref-type="bibr" rid="scirp.54867-ref13">13</xref>] algorithms. It also uses four consecutive characters to compute the shift values such as RS-A [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] and ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] algorithms. In addition to that, it uses the same comparison technique between the pattern and the text that was used in ETSW [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] .</p><p>This paper compares between the new algorithms of EERS-A, ETSW [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] and ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] . The results showed that the new algorithm is better than others as explained in Section 5. The reminder of this paper is organized as follows: Section 2 consists of related works; Section 3 explains EERS-A algorithm; Section 4 covers the analysis. Finally, the conclusion and the future work are presented in Section 6.</p></sec><sec id="s2"><title>2. Related Works</title><p>Pattern matching algorithms were needed in many applications [<xref ref-type="bibr" rid="scirp.54867-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref14">14</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref18">18</xref>] - [<xref ref-type="bibr" rid="scirp.54867-ref20">20</xref>] . Some algorithms made enhancement in a memory used in preprocessing phase, while others try to make the searching process faster and more efficient [<xref ref-type="bibr" rid="scirp.54867-ref8">8</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref9">9</xref>] [<xref ref-type="bibr" rid="scirp.54867-ref21">21</xref>] .</p><p>The Berry-Ravindran algorithm (BR) [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] made enhancement in Boyer Moore algorithm [<xref ref-type="bibr" rid="scirp.54867-ref16">16</xref>] . In a case of a mismatch between the text and the pattern window Boyer uses one consecutive character in the text immediately to the right of the pattern window to determine amount of shift the window must move, on the other hand Berry- Ravindran uses two consecutive characters.</p><p>Many enhancements made in Berry-Ravindran algorithm (BR) [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] , some algorithms changed the searching process but on the other hand they used the same bad character shift values, bad character shift depends on using two consecutive characters immediately that follow the text such as TSW [<xref ref-type="bibr" rid="scirp.54867-ref12">12</xref>] and ETSW [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] . Others made enhancement on the shift values such as RS-A [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] and ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] these two algorithms changed the shift values by using four consecutive character instead of two, also EBR [<xref ref-type="bibr" rid="scirp.54867-ref13">13</xref>] algorithm made modifications on Berry-Ra- vindran bad character shift by depending on using three consecutive characters.</p><p>Two Sliding Windows algorithm TSW [<xref ref-type="bibr" rid="scirp.54867-ref12">12</xref>] used the same preprocessing technique used in BR [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] but made enhancements on the searching phase. In a case of a mismatch between the pattern and text, it uses two consecutive characters to determine the amount of shift the pattern window must slide which is the same technique used in BR [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] , but instead of using one pattern window to scan the text as in BR [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] it uses two sliding windows that scan it in parallel.</p><p>Searching process become faster in Enhanced Two Sliding Window algorithm (ETSW) [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] . ETSW [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] made enhancements on TSW [<xref ref-type="bibr" rid="scirp.54867-ref12">12</xref>] by minimizing the number of comparisons needed but it doesn’t make any changes on the number of attempts. The reason for this is that two algorithms used the same preprocessing techniques and also used the two sliding window, the only difference between them is related to the idea that TSW [<xref ref-type="bibr" rid="scirp.54867-ref12">12</xref>] compares the text with the pattern from one side of the pattern while ETSW [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] compare the text with the pattern from the both sides of the pattern at the same time, the best time complexity is <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x5.png" xlink:type="simple"/></inline-formula> and the worst case time complexity is<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x6.png" xlink:type="simple"/></inline-formula>. The preprocess time complexity is<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x7.png" xlink:type="simple"/></inline-formula>.</p><p>RS-A [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] algorithm used only one window to search for a pattern p in a text t from the right side of the text. In order to make the searching process faster ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] algorithms made enhancements on RS-A by using two windows instead of one. The left window aligned with the text from the left and in a case of a mismatch the window will be shifted to the right, and the right window aligned with text from the right and in a case of a mismatch the window will be shifted to the left. The two windows slide in parallel. The search will stop either when the pattern is found or in a case the pattern not found at all.</p><p>The EERS-A made enhancement on ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] , it uses the same preprocessing technique that depends on using four consecutive characters to determine the amount of shift, it also uses two sliding windows to scan the text from the left and right sides at the same time. Enhancements made on a comparison between the text and the pattern, in this case it uses the same method used in ETSW [<xref ref-type="bibr" rid="scirp.54867-ref10">10</xref>] , which make comparisons between the text and the pattern from both sides of the pattern at the same time. It is obvious from the results that there are no changes in average number of attempts in both ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] and EERS-A, on the other hand there are a clear differences in average number of comparisons. The EERS-A is more efficient and faster.</p></sec><sec id="s3"><title>3. The Enhanced ERS-A Algorithm</title><p>EERS-A algorithm improved the searching process by scanning the pattern as well as the text from both sides simultaneously. EERS-A used two sliding windows to scan the text from both sides at the same time; also comparisons between the pattern and the text happened from both sides of the pattern.</p><p>EERS-A algorithm used the same searching technique used in ERS-A, they uses two sliding windows to search for a pattern p in a text t. Two sliding windows scan the text from the left and right side at the same time and in a case of a mismatch both algorithms will use RS-A bad character shift function [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] . The searching process will stop either when a pattern is found or in a case a pattern is not found in the text at all.</p><p>The main difference between EERS-A and ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] algorithms is that in ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] comparisons between the pattern and the text happened only from the left side of the pattern while in EERS-A comparisons done from left and right sides of the pattern at the same time.</p></sec><sec id="s4"><title>4. Pre-Processing Phase</title><p>Two arrays are generated in this phase nextl and nextr, each array is one-dimensional array. The values of the nextr array are calculated according to RS-A algorithm [<xref ref-type="bibr" rid="scirp.54867-ref5">5</xref>] . Initially the indexes of the four consecutive characters of the text after aligning it with the right window are (n − m − 4), (n − m − 3), (n − m − 2) and (n − m − 1) for a, b, c and d respectively, which are used to calculate the shift values in a case of a mismatch from the right side of the text as in Equation (1).</p><disp-formula id="scirp.54867-formula1638"><label>(1)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/5-9302043x8.png"  xlink:type="simple"/></disp-formula><p>On the other hand, the values of the nextl array are calculated according ERS-A algorithm [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] . The shift values are calculated by using four consecutive text characters a, b, c and d which are aligned immediately to the right of the left sliding window. Initially, the indexes of the four consecutive characters in the text string needed to search the text from the left side are (m + 1), (m + 2), (m + 3) and (m + 4) for a, b, c and d respectively as in Equation (2).</p><disp-formula id="scirp.54867-formula1639"><label>(2)</label><graphic position="anchor" xlink:href="http://html.scirp.org/file/5-9302043x9.png"  xlink:type="simple"/></disp-formula><p>The pre-processing phase is the same in both ERS-A and EERS-A algorithms but the searching phase is enhanced in EERS-A.</p></sec><sec id="s5"><title>5. Searching Phase</title><p>In EERS-A algorithm the searching process started by aligning two windows with the text, the left window aligned with the beginning of the text and the right window aligned with the end of the text. In case of a mismatch the proposed window will be shifted according to next array values calculated in a preprocessing phase; the left window will be shifted to the right and the right window will be shifted to left.</p><p>Four pointers will be used in a comparison process between the text and the pattern, two for each window. The left window uses the L and temp_newlindex pointers while the right window uses the R and temp_newrindex pointers.</p><p>Comparisons between the text and the pattern from both sides is the same, in each window the first character of the pattern is compared with the corresponding text character and at the same time the last character of the pattern is compared with the corresponding character in the text. Each window uses different pointers as explained below:</p></sec><sec id="s6"><title>6. Left_Window Search Process</title><p>After aligning the left window with the text from the left, comparisons between the pattern and the text will be done using two pointers, L and temp_newlindex, L pointer points at the last character of the pattern and the temp_newlindex points at the first character of the pattern, comparisons are made between the pointers and the corresponding characters of the text.</p><p>If a mismatch occurs in any pointer a shift will occurs according to the ERS-A bad character algorithm.</p><p>In case of a match the two pointers will move.</p><p>The L pointer will move to the left and the temp_newlindex will move to the right. A movement of pointers in a case of a match will stop either when two pointers reach the middle of the pattern or when the L pointer is less than or equal the temp_newlindex, in either case the pattern is found.</p></sec><sec id="s7"><title>7. Right_Window Search Process</title><p>After aligning the right window with the text from the right, comparisons between the pattern and the text will be done using two pointers, R and temp_newrindex, R pointer points at the first character of the pattern and the temp_newrindex points at the last character of the pattern, comparisons are made between the pointers and the corresponding characters of the text.</p><p>If a mismatch occurs in any pointer a shift will occurs according to the ERS-A bad character algorithm. In case of a match the two pointers will move. The R pointer will move to the right and the temp_newrindex will move to the left. A movement of pointers in a case of a match will stop either when two pointers reach the middle of the pattern or when the R pointer is less than or equal the temp_newrindex, in either case the pattern is found.</p><p>The proposed EERS-A algorithm is explained in <xref ref-type="fig" rid="fig1">Figure 1</xref>.</p></sec><sec id="s8"><title>8. Working Example</title><p>In this section, we will give an example to explain the new algorithm.</p><p>Given:</p><p>Pattern (P) = “ACCBCBAC”, m = 8,</p><p>Text (T) = “ABCDABADBACEDABACCBCBACABADBCEDABADDDBACCBABCBCBAB”, n = 50.</p></sec><sec id="s9"><title>9. Pre-Processing Phase</title><p>Initially, shiftl = shiftr = m + 4 = 12.</p><p>The shift values are stored in two arrays nextl and nextr as shown in <xref ref-type="fig" rid="fig2">Figure 2</xref>(a) and <xref ref-type="fig" rid="fig2">Figure 2</xref>(b) respectively.</p><p>To build the two next arrays (nextl and nextr), we take each four consecutive characters of the pattern and</p><fig id="fig1"  position="float"><label><xref ref-type="fig" rid="fig1">Figure 1</xref></label><caption><title> EERS-A flowchart</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/5-9302043x10.png"/></fig><fig-group id="fig2"><label><xref ref-type="fig" rid="fig2">Figure 2</xref></label><caption><title> The nextl and nextr arrays.</title></caption><fig id ="fig2_1"><label></label><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/5-9302043x11.png"/></fig><fig id ="fig2_2"><label></label><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/5-9302043x12.png"/></fig></fig-group><p>give it an index starting from 0. For example for the pattern structure ACCBCBAC, the consecutive characters ACCB, CCBC, CBCB, BCBA and CBAC are given the indexes 0, 1, 2, 3 and 4 respectively.</p><p>The shift values for the nextr array are calculated according to Equation (1) while the shift values for the nextl array are calculated according to Equation (2).</p></sec><sec id="s10"><title>10. Searching Phase</title><p>The searching process for the pattern P is explained through the working example as shown in <xref ref-type="fig" rid="fig3">Figure 3</xref>.</p><sec id="s10_1"><title>10.1. First Attempt</title><p>In the first attempt (see <xref ref-type="fig" rid="fig3">Figure 3</xref>(a)), we align the left sliding window with the text from the left. In this case, a comparison is made between the text character located at index 0 (character A) with the leftmost character in the pattern (character A) although a match occurs, the total result is a mismatch since at the same time a comparison must be made between the text character at index 7 (character D) with the rightmost character in the pattern (character C); therefore we take the four consecutive characters of the text at index 8, 9, 10 and 11 which are (B, A, C and E) respectively. To determine the amount of shift (shiftl) we have to do the following:</p><p>Since if<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x13.png" xlink:type="simple"/></inline-formula>; BAC = BAC then according to a preprocessing algorithm the shift value will be 3.</p></sec><sec id="s10_2"><title>10.2. Second Attempt</title><p>In the second attempt (see <xref ref-type="fig" rid="fig3">Figure 3</xref>(b)), we align the right sliding window with the text from the right. In this case, a match occurs between text character at index 42 (A) and left most character of the pattern character A but a mismatch occurs between the last text character B with the last pattern character C so as a total result,</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/5-9302043x14.png"/></fig><p>there is a mismatch; therefore we take the four consecutive characters from the text at index 38, 39, 40 and 41 which are A, C, C and B respectively. To determine the amount of shift (shiftr), we have to do the following:</p><p>a) We find the index of ACCB in the pattern which is 0.</p><p>b) Since we search the text from the right side we use nextr array, and shiftr = nextr[<xref ref-type="bibr" rid="scirp.54867-ref0">0</xref>] = 4; therefore the window will be shifted to the left 4 steps.</p></sec><sec id="s10_3"><title>10.3. Third Attempt</title><p>In the third attempt (see <xref ref-type="fig" rid="fig3">Figure 3</xref>(c)), a mismatch occurs from the left between the text character at index 3 (character D) and the leftmost character in the pattern (character A) while there is a match between the text character at index 10 (character C) and the rightmost character in the pattern (character C); therefore we take the four consecutive characters from the text at indexes 11, 12, 13 and 14 which are E, D, A and B respectively, since EDAB is not found in the pattern, so the window will be shifted to the right 12 steps.</p></sec><sec id="s10_4"><title>10.4. Fourth Attempt</title><p>In the fourth attempt (see <xref ref-type="fig" rid="fig3">Figure 3</xref>(d)), a comparison is made between the text character located at index 38 (character A) with the leftmost character in the pattern (character A) at the same time a comparison must be made between the text character at index 45 (character B) with the rightmost character in the pattern (character C) since there is a mismatch we take the four consecutive characters of the text at index 34, 35, 36 and 37 which are D, D, D and A respectively; since DDDB is not found in the pattern, so the window will be shifted to the left 12 steps.</p></sec><sec id="s10_5"><title>10.5. Fifth Attempt</title><p>We align the left most character of the pattern P[<xref ref-type="bibr" rid="scirp.54867-ref0">0</xref>] with T[<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>]. A comparison between the pattern and the text characters leads to a complete match at index 15. In this case, the occurrence of the pattern is found using the left window.</p></sec></sec><sec id="s11"><title>11. Analysis</title><p>Preposition 1: The space complexity is <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x15.png" xlink:type="simple"/></inline-formula> where m is the pattern length.</p><p>Preposition 2: The pre-process time complexity is <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x16.png" xlink:type="simple"/></inline-formula></p><p>Lemma 1: The worst case time complexity is<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x17.png" xlink:type="simple"/></inline-formula>.</p><p>Proof: The worst occurs when a match between the text and patterns occurs in all characters except a character at index m/2 in the pattern, and if at the same time the shift values in case of a mismatch equal to 1.</p><p>Lemma 2: The best case time complexity is<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x18.png" xlink:type="simple"/></inline-formula>.</p><p>Proof: The best case occurs when the pattern is found in the leftmost or the rightmost sides of the text.</p><p>Lemma 3: The average case time complexity is <inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x19.png" xlink:type="simple"/></inline-formula></p><p>Proof: The average case occurs when the four consecutive characters of the text directly following the sliding window is not found in the pattern. In this case, the shift value will be (m + 4) and hence the time complexity is<inline-formula><inline-graphic xlink:href="http://html.scirp.org/file/5-9302043x20.png" xlink:type="simple"/></inline-formula>.</p></sec><sec id="s12"><title>12. Experimental Results and Discussion</title><p>Several experiments have been done using Book 1 from the Calgary corpus [<xref ref-type="bibr" rid="scirp.54867-ref22">22</xref>] to be the text in most of searching algorithms. Book 1 consists of 141,274 words (752,149 characters). Book 1 consists of 141,274 words (752,149 characters). Patterns of different lengths are also taken from Book 1.</p><p><xref ref-type="table" rid="table1">Table 1</xref> shows the results of comparing the algorithms ETSW, ERS-A and EERS-A.</p><p>In <xref ref-type="table" rid="table1">Table 1</xref>, the first column related to the pattern length; second column is the number of words in a certain length. It can be clearly seen that the number of attempts in EERS-A and ERS-A are the same since the two algorithms use the same shifting techniques in a case of a mismatch, and according to the results it’s clear that the number of comparisons in EERS-A are better than all other algorithms. For example, as shown in <xref ref-type="table" rid="table1">Table 1</xref>, 2896 words of length 6, the average number of comparisons in ETSW is 7633, in ERS-A is 6750 and in the new algorithms is 6212, which is the minimum value among the others values.</p><p>ETSW algorithm and EERS-A algorithm use the same comparison technique, they use two sliding windows to scan the text, and in addition to that they use the same technique when comparing the text with the pattern where comparisons happened from both sides of the pattern simultaneously. It is clear that the number of comparisons and attempts in EERS-A algorithm are better than ERS-A algorithm and this refers to using different shifting technique. While ETSW uses Berry-Ravindran (BR) [<xref ref-type="bibr" rid="scirp.54867-ref15">15</xref>] bad character shift values which uses two consecutive characters, EERS-A uses ERS-A [<xref ref-type="bibr" rid="scirp.54867-ref11">11</xref>] bad character shift values that uses four consecutive characters.</p><p><xref ref-type="table" rid="table2">Table 2</xref> shows the average number of attempts and comparisons for 100 words taken from the right side of Book1. It is clear that EERS-A is the best among all others according to the number of comparisons and the same results can be seen in <xref ref-type="table" rid="table3">Table 3</xref> and <xref ref-type="table" rid="table4">Table 4</xref>.</p><p><xref ref-type="table" rid="table5">Table 5</xref> and <xref ref-type="fig" rid="fig4">Figure 4</xref> show the average number of comparisons needed to search for patterns with different lengths. The results show that EERS-A finds the patterns with minimum number of comparisons compared with</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> The average number of attempts and comparisons of ETSW, ERS-A and EERS-A algorithms</title></caption><table><tbody><thead><tr><th align="center" valign="middle"  rowspan="2"  >Pattern length</th><th align="center" valign="middle"  rowspan="2"  >Number of words</th><th align="center" valign="middle"  colspan="2"  >ETSW</th><th align="center" valign="middle"  colspan="2"  >ERS-A</th><th align="center" valign="middle"  colspan="2"  >EERS-A</th></tr></thead><tr><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >4535</td><td align="center" valign="middle" >4456</td><td align="center" valign="middle" >3549</td><td align="center" valign="middle" >3533</td><td align="center" valign="middle" >3880</td><td align="center" valign="middle" >3533</td><td align="center" valign="middle" >2813</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >2896</td><td align="center" valign="middle" >7596</td><td align="center" valign="middle" >7633</td><td align="center" valign="middle" >6166</td><td align="center" valign="middle" >6750</td><td align="center" valign="middle" >6166</td><td align="center" valign="middle" >6212</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >1988</td><td align="center" valign="middle" >9341</td><td align="center" valign="middle" >9118</td><td align="center" valign="middle" >7737</td><td align="center" valign="middle" >8506</td><td align="center" valign="middle" >7737</td><td align="center" valign="middle" >7636</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >1167</td><td align="center" valign="middle" >10056</td><td align="center" valign="middle" >10115</td><td align="center" valign="middle" >8451</td><td align="center" valign="middle" >9319</td><td align="center" valign="middle" >8451</td><td align="center" valign="middle" >8525</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >681</td><td align="center" valign="middle" >9538</td><td align="center" valign="middle" >9590</td><td align="center" valign="middle" >8106</td><td align="center" valign="middle" >8957</td><td align="center" valign="middle" >8106</td><td align="center" valign="middle" >8171</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >382</td><td align="center" valign="middle" >9283</td><td align="center" valign="middle" >9339</td><td align="center" valign="middle" >7970</td><td align="center" valign="middle" >8830</td><td align="center" valign="middle" >7970</td><td align="center" valign="middle" >8042</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >191</td><td align="center" valign="middle" >5451</td><td align="center" valign="middle" >5482</td><td align="center" valign="middle" >4701</td><td align="center" valign="middle" >5146</td><td align="center" valign="middle" >4701</td><td align="center" valign="middle" >4742</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >69</td><td align="center" valign="middle" >6384</td><td align="center" valign="middle" >6433</td><td align="center" valign="middle" >5589</td><td align="center" valign="middle" >6286</td><td align="center" valign="middle" >5589</td><td align="center" valign="middle" >5653</td></tr><tr><td align="center" valign="middle" >13</td><td align="center" valign="middle" >55</td><td align="center" valign="middle" >7947</td><td align="center" valign="middle" >7986</td><td align="center" valign="middle" >6955</td><td align="center" valign="middle" >7587</td><td align="center" valign="middle" >6955</td><td align="center" valign="middle" >7004</td></tr><tr><td align="center" valign="middle" >14</td><td align="center" valign="middle" >139</td><td align="center" valign="middle" >19437</td><td align="center" valign="middle" >19535</td><td align="center" valign="middle" >17115</td><td align="center" valign="middle" >18776</td><td align="center" valign="middle" >17115</td><td align="center" valign="middle" >17242</td></tr><tr><td align="center" valign="middle" >15</td><td align="center" valign="middle" >32</td><td align="center" valign="middle" >19682</td><td align="center" valign="middle" >19782</td><td align="center" valign="middle" >17385</td><td align="center" valign="middle" >19198</td><td align="center" valign="middle" >17385</td><td align="center" valign="middle" >17519</td></tr><tr><td align="center" valign="middle" >16</td><td align="center" valign="middle" >10</td><td align="center" valign="middle" >20029</td><td align="center" valign="middle" >20092</td><td align="center" valign="middle" >17722</td><td align="center" valign="middle" >19147</td><td align="center" valign="middle" >17722</td><td align="center" valign="middle" >17807</td></tr><tr><td align="center" valign="middle" >17</td><td align="center" valign="middle" >3</td><td align="center" valign="middle" >21897</td><td align="center" valign="middle" >22147</td><td align="center" valign="middle" >19521</td><td align="center" valign="middle" >22669</td><td align="center" valign="middle" >19521</td><td align="center" valign="middle" >19855</td></tr></tbody></table></table-wrap><table-wrap id="table2" ><label><xref ref-type="table" rid="table2">Table 2</xref></label><caption><title> The average number of attempts and comparisons performed to search for (100) patterns selected from the right side of the text</title></caption><table><tbody><thead><tr><th align="center" valign="middle"  rowspan="2"  >Pattern length</th><th align="center" valign="middle"  rowspan="2"  >Number of words</th><th align="center" valign="middle"  colspan="2"  >ETSW</th><th align="center" valign="middle"  colspan="2"  >ERS-A</th><th align="center" valign="middle"  colspan="2"  >EERS-A</th></tr></thead><tr><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >185</td><td align="center" valign="middle" >187</td><td align="center" valign="middle" >146</td><td align="center" valign="middle" >163</td><td align="center" valign="middle" >146</td><td align="center" valign="middle" >148</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >227</td><td align="center" valign="middle" >230</td><td align="center" valign="middle" >182</td><td align="center" valign="middle" >205</td><td align="center" valign="middle" >182</td><td align="center" valign="middle" >186</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >347</td><td align="center" valign="middle" >351</td><td align="center" valign="middle" >286</td><td align="center" valign="middle" >324</td><td align="center" valign="middle" >286</td><td align="center" valign="middle" >291</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >504</td><td align="center" valign="middle" >510</td><td align="center" valign="middle" >424</td><td align="center" valign="middle" >476</td><td align="center" valign="middle" >424</td><td align="center" valign="middle" >431</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >670</td><td align="center" valign="middle" >677</td><td align="center" valign="middle" >571</td><td align="center" valign="middle" >640</td><td align="center" valign="middle" >571</td><td align="center" valign="middle" >579</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >1160</td><td align="center" valign="middle" >1170</td><td align="center" valign="middle" >999</td><td align="center" valign="middle" >1117</td><td align="center" valign="middle" >999</td><td align="center" valign="middle" >1011</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >622</td><td align="center" valign="middle" >628</td><td align="center" valign="middle" >529</td><td align="center" valign="middle" >597</td><td align="center" valign="middle" >529</td><td align="center" valign="middle" >536</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >865</td><td align="center" valign="middle" >878</td><td align="center" valign="middle" >756</td><td align="center" valign="middle" >860</td><td align="center" valign="middle" >756</td><td align="center" valign="middle" >774</td></tr></tbody></table></table-wrap><table-wrap id="table3" ><label><xref ref-type="table" rid="table3">Table 3</xref></label><caption><title> The average number of attempts and comparisons performed to search for (100) patterns selected from the middle of the text</title></caption><table><tbody><thead><tr><th align="center" valign="middle"  rowspan="2"  >Pattern length</th><th align="center" valign="middle"  rowspan="2"  >Number of words</th><th align="center" valign="middle"  colspan="2"  >ETSW</th><th align="center" valign="middle"  colspan="2"  >ERS-A</th><th align="center" valign="middle"  colspan="2"  >EERS-A</th></tr></thead><tr><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >13965</td><td align="center" valign="middle" >11618</td><td align="center" valign="middle" >11038</td><td align="center" valign="middle" >11970</td><td align="center" valign="middle" >11038</td><td align="center" valign="middle" >10875</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >16682</td><td align="center" valign="middle" >16771</td><td align="center" valign="middle" >13536</td><td align="center" valign="middle" >14870</td><td align="center" valign="middle" >13536</td><td align="center" valign="middle" >13648</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >27267</td><td align="center" valign="middle" >26242</td><td align="center" valign="middle" >22607</td><td align="center" valign="middle" >24971</td><td align="center" valign="middle" >22607</td><td align="center" valign="middle" >22179</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >27830</td><td align="center" valign="middle" >28015</td><td align="center" valign="middle" >23385</td><td align="center" valign="middle" >25976</td><td align="center" valign="middle" >23385</td><td align="center" valign="middle" >23617</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >33929</td><td align="center" valign="middle" >34069</td><td align="center" valign="middle" >28764</td><td align="center" valign="middle" >31541</td><td align="center" valign="middle" >28764</td><td align="center" valign="middle" >28943</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >29676</td><td align="center" valign="middle" >29845</td><td align="center" valign="middle" >25471</td><td align="center" valign="middle" >28193</td><td align="center" valign="middle" >25471</td><td align="center" valign="middle" >25689</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >23195</td><td align="center" valign="middle" >23242</td><td align="center" valign="middle" >19886</td><td align="center" valign="middle" >21119</td><td align="center" valign="middle" >19886</td><td align="center" valign="middle" >19946</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >26806</td><td align="center" valign="middle" >27009</td><td align="center" valign="middle" >23484</td><td align="center" valign="middle" >26507</td><td align="center" valign="middle" >23484</td><td align="center" valign="middle" >23761</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 attempts and comparisons performed to search for (100) patterns selected from the left side of the text</title></caption><table><tbody><thead><tr><th align="center" valign="middle"  rowspan="2"  >Pattern length</th><th align="center" valign="middle"  rowspan="2"  >Number of words</th><th align="center" valign="middle"  colspan="2"  >ETSW</th><th align="center" valign="middle"  colspan="2"  >ERS-A</th><th align="center" valign="middle"  colspan="2"  >EERS-A</th></tr></thead><tr><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Attempts</td><td align="center" valign="middle" >Comparisons</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >271</td><td align="center" valign="middle" >270</td><td align="center" valign="middle" >216</td><td align="center" valign="middle" >238</td><td align="center" valign="middle" >216</td><td align="center" valign="middle" >218</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >364</td><td align="center" valign="middle" >368</td><td align="center" valign="middle" >295</td><td align="center" valign="middle" >326</td><td align="center" valign="middle" >295</td><td align="center" valign="middle" >299</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >402</td><td align="center" valign="middle" >405</td><td align="center" valign="middle" >333</td><td align="center" valign="middle" >372</td><td align="center" valign="middle" >333</td><td align="center" valign="middle" >337</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >536</td><td align="center" valign="middle" >541</td><td align="center" valign="middle" >451</td><td align="center" valign="middle" >499</td><td align="center" valign="middle" >451</td><td align="center" valign="middle" >457</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >776</td><td align="center" valign="middle" >783</td><td align="center" valign="middle" >660</td><td align="center" valign="middle" >730</td><td align="center" valign="middle" >660</td><td align="center" valign="middle" >668</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >1579</td><td align="center" valign="middle" >1593</td><td align="center" valign="middle" >1361</td><td align="center" valign="middle" >1517</td><td align="center" valign="middle" >1361</td><td align="center" valign="middle" >1378</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >619</td><td align="center" valign="middle" >624</td><td align="center" valign="middle" >531</td><td align="center" valign="middle" >573</td><td align="center" valign="middle" >531</td><td align="center" valign="middle" >537</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >100</td><td align="center" valign="middle" >1667</td><td align="center" valign="middle" >1685</td><td align="center" valign="middle" >1459</td><td align="center" valign="middle" >1641</td><td align="center" valign="middle" >1459</td><td align="center" valign="middle" >1480</td></tr></tbody></table></table-wrap><table-wrap id="table5" ><label><xref ref-type="table" rid="table5">Table 5</xref></label><caption><title> The average number of attempts and comparisons for patterns with different lengths</title></caption><table><tbody><thead><tr><th align="center" valign="middle"  rowspan="2"  >Pattern length</th><th align="center" valign="middle"  rowspan="2"  >Number of words</th><th align="center" valign="middle" >TSW</th><th align="center" valign="middle" >ETSW</th><th align="center" valign="middle" >RS-A</th><th align="center" valign="middle" >ERS-A</th><th align="center" valign="middle" >EERS-A</th></tr></thead><tr><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Comparisons</td><td align="center" valign="middle" >Comparisons</td></tr><tr><td align="center" valign="middle" >5</td><td align="center" valign="middle" >4535</td><td align="center" valign="middle" >4896</td><td align="center" valign="middle" >3549</td><td align="center" valign="middle" >8191</td><td align="center" valign="middle" >3880</td><td align="center" valign="middle" >2813</td></tr><tr><td align="center" valign="middle" >6</td><td align="center" valign="middle" >2896</td><td align="center" valign="middle" >8311</td><td align="center" valign="middle" >7633</td><td align="center" valign="middle" >9556</td><td align="center" valign="middle" >6750</td><td align="center" valign="middle" >6212</td></tr><tr><td align="center" valign="middle" >7</td><td align="center" valign="middle" >1988</td><td align="center" valign="middle" >10263</td><td align="center" valign="middle" >9118</td><td align="center" valign="middle" >10638</td><td align="center" valign="middle" >8506</td><td align="center" valign="middle" >7636</td></tr><tr><td align="center" valign="middle" >8</td><td align="center" valign="middle" >1167</td><td align="center" valign="middle" >11087</td><td align="center" valign="middle" >10115</td><td align="center" valign="middle" >11922</td><td align="center" valign="middle" >9319</td><td align="center" valign="middle" >8525</td></tr><tr><td align="center" valign="middle" >9</td><td align="center" valign="middle" >681</td><td align="center" valign="middle" >10538</td><td align="center" valign="middle" >9590</td><td align="center" valign="middle" >12911</td><td align="center" valign="middle" >8957</td><td align="center" valign="middle" >8171</td></tr><tr><td align="center" valign="middle" >10</td><td align="center" valign="middle" >382</td><td align="center" valign="middle" >10272</td><td align="center" valign="middle" >9339</td><td align="center" valign="middle" >12927</td><td align="center" valign="middle" >8830</td><td align="center" valign="middle" >8042</td></tr><tr><td align="center" valign="middle" >11</td><td align="center" valign="middle" >191</td><td align="center" valign="middle" >5967</td><td align="center" valign="middle" >5482</td><td align="center" valign="middle" >11672</td><td align="center" valign="middle" >5146</td><td align="center" valign="middle" >4742</td></tr><tr><td align="center" valign="middle" >12</td><td align="center" valign="middle" >69</td><td align="center" valign="middle" >7168</td><td align="center" valign="middle" >6433</td><td align="center" valign="middle" >9030</td><td align="center" valign="middle" >6286</td><td align="center" valign="middle" >5653</td></tr><tr><td align="center" valign="middle" >13</td><td align="center" valign="middle" >55</td><td align="center" valign="middle" >8673</td><td align="center" valign="middle" >7986</td><td align="center" valign="middle" >9422</td><td align="center" valign="middle" >7587</td><td align="center" valign="middle" >7004</td></tr><tr><td align="center" valign="middle" >14</td><td align="center" valign="middle" >139</td><td align="center" valign="middle" >21319</td><td align="center" valign="middle" >19535</td><td align="center" valign="middle" >17845</td><td align="center" valign="middle" >18776</td><td align="center" valign="middle" >17242</td></tr><tr><td align="center" valign="middle" >15</td><td align="center" valign="middle" >32</td><td align="center" valign="middle" >21739</td><td align="center" valign="middle" >19782</td><td align="center" valign="middle" >18318</td><td align="center" valign="middle" >19198</td><td align="center" valign="middle" >17519</td></tr><tr><td align="center" valign="middle" >16</td><td align="center" valign="middle" >10</td><td align="center" valign="middle" >21596</td><td align="center" valign="middle" >20092</td><td align="center" valign="middle" >23531</td><td align="center" valign="middle" >19147</td><td align="center" valign="middle" >17807</td></tr><tr><td align="center" valign="middle" >17</td><td align="center" valign="middle" >3</td><td align="center" valign="middle" >25404</td><td align="center" valign="middle" >22147</td><td align="center" valign="middle" >23119</td><td align="center" valign="middle" >22669</td><td align="center" valign="middle" >19855</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 TSW, ETSW, RS-A and ERS-A, EERS-A algorithms</title></caption><graphic mimetype="image"   position="float"  xlink:type="simple"  xlink:href="http://html.scirp.org/file/5-9302043x21.png"/></fig><p>other algorithms such as TSW, ETSW, RSA and ERS-A. For example, it took EERS-A 8042 comparisons to locate the pattern of length 10 while it took TSW, ETSW, RS-A and ERS-A 10272, 9339, 12927 and 8830 comparisons respectively for the same pattern length. These results show that EERS-A is the best algorithm compared to others.</p></sec><sec id="s13"><title>13. Conclusions and Future Work</title><p>In this paper, we presented a new pattern matching algorithm―Enhanced ERS-A algorithm. The Enhanced ERS-A algorithm enhances the ERS-A’s process by utilizing the idea of the two sliding windows and by making comparisons with the pattern from both sides simultaneously. The comparisons done between the text and the pattern are done from both sides in parallel. This process gives the proposed algorithm a preference over the ERS-A algorithm.</p><p>The Enhanced ERS-A algorithm utilizes the idea of RS shifting algorithm to maximize the shift values. To assess the performance of the proposed algorithm, we considered ETSW and ERS-A algorithms for comparison with the proposed algorithm. The experimental results show that the Enhanced ERS-A shows better results in the number of comparisons performed.</p></sec></body><back><ref-list><title>References</title><ref id="scirp.54867-ref1"><label>1</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 id="scirp.54867-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Hlayel Abdallah, A. and Hnaif Adnan, A. (2014) A New Exact Pattern Matching Algorithm (WEMA). Journal of Applied Sciences, 14, 193-196.</mixed-citation></ref><ref id="scirp.54867-ref3"><label>3</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.54867-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Bhandaru, J. and Kumar, A. (2014) A Survey of Fast Hybrid String Matching Algorithms. International Journal of Emerging Sciences, 4, 24-37.</mixed-citation></ref><ref id="scirp.54867-ref5"><label>5</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). International Journal of Computer Science Issues, 10, 59-65.</mixed-citation></ref><ref id="scirp.54867-ref6"><label>6</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.54867-ref7"><label>7</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.54867-ref8"><label>8</label><mixed-citation publication-type="book" xlink:type="simple">Berry, T. and Ravindran, S. (2001) A Fast String Matching Algorithm and Experimental Results. In: Holub, J. and Simanek, M., Eds., Proceedings of the Prague Stringology Club Workshop’99, Colla-borative Report DC-99-05, Czech Technical University, Prague, 16-26.</mixed-citation></ref><ref id="scirp.54867-ref9"><label>9</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.</mixed-citation></ref><ref id="scirp.54867-ref10"><label>10</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.54867-ref11"><label>11</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.54867-ref12"><label>12</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.54867-ref13"><label>13</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.54867-ref14"><label>14</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.</mixed-citation></ref><ref id="scirp.54867-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.54867-ref16"><label>16</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.54867-ref17"><label>17</label><mixed-citation publication-type="other" xlink:type="simple">Bhukya, R. and Somayajulu, D. (2011) Multiple Pattern Matching Algorithm Using Pair-Count. IJCSI International Journal of Computer Science Issues, 8, 1694-0814.</mixed-citation></ref><ref id="scirp.54867-ref18"><label>18</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 Bio-Logical Sequences. International Journal of Engineering and Innovative Technology (IJEIT), 1, 116-118.</mixed-citation></ref><ref id="scirp.54867-ref19"><label>19</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.54867-ref20"><label>20</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.54867-ref21"><label>21</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.54867-ref22"><label>22</label><mixed-citation publication-type="other" xlink:type="simple">El Emary, I.M.M. and Jaber, M.S.M. (2008) A New Approach for Solving String Matching Problem through Splitting the Unchangeable Text. World Applied Sciences Journal, 4, 626-633.</mixed-citation></ref></ref-list></back></article>