Segment and Fenwick Trees for Approximate Order Preserving Matching

  • Rafael Niquefa
  • Juan MendivelsoEmail author
  • Germán Hernández
  • Yoan Pinzón
Conference paper
Part of the Communications in Computer and Information Science book series (CCIS, volume 742)


In this paper we combine two string searching related problems: the approximate string matching under parameters \(\delta \) and \(\gamma \), and the order preserving matching problem. Order-preserving matching regards the internal structure of the strings rather than their absolute values while matching under \(\delta \) and \(\gamma \) distances permit a level of error. We formally define the \(\delta \gamma \)–order-preserving matching problem. We designed two algorithms for it based on the segment tree and the Fenwick tree, respectively. Also, we design and implement in C++ and an experimental setup to compare these algorithms with the naive solution and the updateBA algorithm introduced in [22]. The data structure based algorithms show better experimental performance due to their better lower bound of \(\varOmega (n \lg n)\) complexity.


String searching Strings similarity metric Fenwick tree Binary indexed tree Segment tree 


  1. 1.
    de Berg, M., Cheong, O., van Kreveld, M., Overmars, M.: More Geometric Data Structures, pp. 219–241. Springer, Heidelberg (2008)Google Scholar
  2. 2.
    Brass, P.: Advanced Data Structures. Cambridge University Press, Cambridge (2008). Cambridge books onlineCrossRefzbMATHGoogle Scholar
  3. 3.
    Cambouropoulos, E., Crochemore, M., Iliopoulos, C., Mouchard, L., Pinzon, Y.: Algorithms for computing approximate repetitions in musical sequences. Int. J. Comput. Math. 79(11), 1135–1148 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Chhabra, T., Kulekci, M.O., Tarhio, J.: Alternative algorithms for order-preserving matching. In: Holub, J., Žďárek, J. (eds.) Proceedings of the Prague Stringology Conference 2015, pp. 36–46. Czech Technical University in Prague, Prague, Czech Republic (2015)Google Scholar
  5. 5.
    Chhabra, T., Tarhio, J.: Order-preserving matching with filtration. In: Gudmundsson, J., Katajainen, J. (eds.) SEA 2014. LNCS, vol. 8504, pp. 307–314. Springer, Cham (2014). doi: 10.1007/978-3-319-07959-2_26 Google Scholar
  6. 6.
    Crawford, T., Iliopoulos, C.S., Raman, R.: String-matching techniques for musical similarity and melodic recognition. Comput. Musicol. 11, 71–100 (1998)Google Scholar
  7. 7.
    Crochemore, M., Iliopoulos, C.S., Kociumaka, T., Kubica, M., Langiu, A., Pissis, S.P., Radoszewski, J., Rytter, W., Waleń, T.: Order-Preserving Incomplete Suffix Trees and Order-Preserving Indexes, pp. 84–95. Springer, Cham (2013)Google Scholar
  8. 8.
    Crochemore, M., Iliopoulos, C.S., Kociumaka, T., Kubica, M., Langiu, A., Pissis, S.P., Radoszewski, J., Rytter, W., Walen, T.: Order-preserving suffix trees and their algorithmic applications. CoRR abs/1303.6872 (2013)Google Scholar
  9. 9.
    Crochemore, M., Iliopoulos, C.S., Kociumaka, T., Kubica, M., Langiu, A., Pissis, S.P., Radoszewski, J., Rytter, W., Waleń, T.: Order-preserving indexing. Theor. Comput. Sci. 638(C), 122–135 (2016)Google Scholar
  10. 10.
    Faro, S., Külekci, M.O.: Efficient algorithms for the order preserving pattern matching problem. CoRR abs/1501.04001 (2015)Google Scholar
  11. 11.
    Fenwick, P.M.: A new data structure for cumulative frequency tables. Softw. Pract. Exp. 24, 327–336 (1994)Google Scholar
  12. 12.
    Gawrychowski, P., Uznański, P.: Order-preserving pattern matching with k mismatches. Theor. Comput. Sci. 638, 136–144 (2016)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Hasan, M.M., Islam, A., Rahman, M.S., Rahman, M.S.: Order Preserving Prefix Tables, pp. 111–116. Springer, Cham (2014)Google Scholar
  14. 14.
    Hasan, M.M., Islam, A., Rahman, M.S., Rahman, M.: Order preserving pattern matching revisited. Pattern Recogn. Lett. 55(C), 15–21 (2015)Google Scholar
  15. 15.
    Kim, J., Eades, P., Fleischer, R., Hong, S.H., Iliopoulos, C.S., Park, K., Puglisi, S.J., Tokuyama, T.: Order-preserving matching. Theor. Comput. Sci. 525, 68–79 (2014). Advances in StringologyGoogle Scholar
  16. 16.
    Kubica, M., Kulczyński, T., Radoszewski, J., Rytter, W.: WaleÅĎ, T.: A linear time algorithm for consecutive permutation pattern matching. Information Processing Letters 113(12), 430–433 (2013)Google Scholar
  17. 17.
    Lee, I., Mendivelso, J., Pinzón, Y.J.: \(\delta \gamma \)-Parameterized Matching, pp. 236–248. Springer, Heidelberg (2009)Google Scholar
  18. 18.
    Mendivelso, J.: Definition and solution of a new string searching variant termed \(\delta \gamma \)-parameterized matching. Master’s thesis, National University of Colombia, Bogota, Colombia (2010)Google Scholar
  19. 19.
    Mendivelso, J., Lee, I., Pinzón, Y.J.: Approximate Function Matching under \(\delta \)- and \(\gamma \)- Distances, pp. 348–359. Springer, Heidelberg (2012)Google Scholar
  20. 20.
    Mendivelso, J., Pino, C., Niño, L.F., Pinzón, Y.: Approximate Abelian Periods to Find Motifs in Biological Sequences, pp. 121–130. Springer, Cham (2015)Google Scholar
  21. 21.
    Mendivelso, J., Pinzón, Y.: A novel approach to approximate parikh matching for comparing composition in biological sequences. In: Proceedings of the 6th International Conference on Bioinformatics and Computational Biology (BICoB 2014) (2014)Google Scholar
  22. 22.
    Niquefa, R., Mendivelso, J., Hernández, G., Pinzón, Y.: Order preserving matching under \(\delta \gamma \)-approximation. In: Congreso Internacional de Ciencias Básicas e Ingeniería (2017)Google Scholar

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  • Rafael Niquefa
    • 1
  • Juan Mendivelso
    • 2
    • 3
    Email author
  • Germán Hernández
    • 4
  • Yoan Pinzón
    • 5
  1. 1.Facultad de Ciencias e IngenieríaPolitecnico Grancolombiano Institucion UniversitariaBogotáColombia
  2. 2.Departamento de MatemáticasUniversidad Nacional de ColombiaBogotáColombia
  3. 3.Facultad de Matemáticas e IngenieríasFundación Universitaria Konrad LorenzBogotáColombia
  4. 4.Departamento de Ingeniería de Sistemas e IndustrialUniversidad Nacional de ColombiaBogotáColombia
  5. 5.Departamento de Electrónica y Ciencias de la ComputaciónPontificia Universidad JaverianaCaliColombia

Personalised recommendations