Strings and Sequences

Part of the SpringerBriefs in Computer Science book series (BRIEFSCOMPUTER)


In the last main chapter we deal with algorithms on strings and sequences. In the first section we consider two elementary data structures: the stack and the queue. We discuss the abundance of flawed metaphors used in education for the queue data structure, and propose better metaphors that should be used for this purpose. In the second section, we give our original exposition of the one-dimensional facility location problem and its solution. Our metaphor easily generalizes to more complicated variants of the problem. Finally, we present our original metaphor that illuminates the inner workings of the Knuth-Morris-Pratt substring search algorithm. This metaphor also leads to a clean implementation that easily avoids off-by-one errors (for which other implementations of KMP are well known).


Time Complexity Facility Location Problem Naive Algorithm Total Time Complexity Ticket Number 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Aho, A.V., Corasick, M.J.: Efficient string matching: an aid to bibliographic search. Commun. ACM 18(6), 333–340 (1975)MathSciNetzbMATHCrossRefGoogle Scholar
  2. 2.
    Bajaj, C.: The algebraic degree of geometric optimization problems. Discrete Comput. Geom. 3, 177–191 (1988). doi: 10.1007/BF02187906 MathSciNetzbMATHCrossRefGoogle Scholar
  3. 3.
    Boyer, R.S., Moore, J.S.: A fast string searching algorithm. Commun. ACM 20(10), 762–772 (1977)zbMATHCrossRefGoogle Scholar
  4. 4.
    Canny, J.F.: The Complexity of Robot Motion Planning. MIT Press (1988)Google Scholar
  5. 5.
    Chazelle, B.: Triangulating a simple polygon in linear time. Discrete Comput. Geom. 6(5), 485–524 (1991)MathSciNetzbMATHCrossRefGoogle Scholar
  6. 6.
    Chen, J., Han, Y.: Shortest paths on a polyhedron, part I: computing shortest paths. Int. J. Comput. Geom. Appl. 6, 127–144 (1996)MathSciNetzbMATHCrossRefGoogle Scholar
  7. 7.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. MIT Press (2009)Google Scholar
  8. 8.
    Hassin, R., Tamir, A.: Improved complexity bounds for location problems on the real line. Oper. Res. Lett. 10, 395–402 (1991)MathSciNetzbMATHCrossRefGoogle Scholar
  9. 9.
    Kariv, O., Hakimi, S.L.: An algorithmic approach to network location problems, Part II: \(p\)-medians. SIAM J. Appl. Math. 37, 539–560 (1979)MathSciNetzbMATHCrossRefGoogle Scholar
  10. 10.
    Karp, R.M., Rabin, M.O.: Efficient randomized pattern-matching algorithms. IBM J. Res. Dev. 31(2), 249–260 (1987)MathSciNetzbMATHCrossRefGoogle Scholar
  11. 11.
    Keogh, J.E., Davidson, K.: Data Structures Demystified. McGraw-Hill (2004)Google Scholar
  12. 12.
    Knuth, D.E., James, H., Morris, J., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6(2), 323–350 (1977)MathSciNetzbMATHCrossRefGoogle Scholar
  13. 13.
    Manber, U., Myers, E.: Suffix arrays: a new method for on-line string searches. SIAM J. Comput. 22(5), 935–948 (1993)MathSciNetzbMATHCrossRefGoogle Scholar
  14. 14.
    Mirzaian, A.: Triangulating Simple Polygons: Pseudo-Triangulations. Tech. rep., York University (1988). Tech. report No. CS-88-12Google Scholar
  15. 15.
    Sedgewick, R., Wayne, K.: Algorithms, 4th edn. Addison-Wesley Professional (2011)Google Scholar
  16. 16.
    Tamir, A.: An \(O(pn^2)\) algorithm for the \(p\)-median and related problems on tree graphs. Oper. Res. Lett. 19, 59–64 (1996)MathSciNetzbMATHCrossRefGoogle Scholar
  17. 17.
    Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14(3), 249–260 (1995)MathSciNetzbMATHCrossRefGoogle Scholar
  18. 18.
    Weiner, P.: Linear pattern matching algorithms. In: Proceedings of the 14th Annual Symposium on Switching and Automata Theory (SWAT 1973), pp. 1–11. IEEE Computer Society (1973)Google Scholar

Copyright information

© The Author(s) 2013

Authors and Affiliations

  1. 1.Department of Computer ScienceComenius UniversityBratislavaSlovakia
  2. 2.Department of Computer ScienceETH ZürichZürichSwitzerland

Personalised recommendations