Abstract
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).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
- 2.
All these values \(S[i]\) are well-defined, because there is always a lemming at the beginning. The value \(S[0]\) is undefined, as there is no lemming to the left of that one.
References
Aho, A.V., Corasick, M.J.: Efficient string matching: an aid to bibliographic search. Commun. ACM 18(6), 333–340 (1975)
Bajaj, C.: The algebraic degree of geometric optimization problems. Discrete Comput. Geom. 3, 177–191 (1988). doi:10.1007/BF02187906
Boyer, R.S., Moore, J.S.: A fast string searching algorithm. Commun. ACM 20(10), 762–772 (1977)
Canny, J.F.: The Complexity of Robot Motion Planning. MIT Press (1988)
Chazelle, B.: Triangulating a simple polygon in linear time. Discrete Comput. Geom. 6(5), 485–524 (1991)
Chen, J., Han, Y.: Shortest paths on a polyhedron, part I: computing shortest paths. Int. J. Comput. Geom. Appl. 6, 127–144 (1996)
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. MIT Press (2009)
Hassin, R., Tamir, A.: Improved complexity bounds for location problems on the real line. Oper. Res. Lett. 10, 395–402 (1991)
Kariv, O., Hakimi, S.L.: An algorithmic approach to network location problems, Part II: \(p\)-medians. SIAM J. Appl. Math. 37, 539–560 (1979)
Karp, R.M., Rabin, M.O.: Efficient randomized pattern-matching algorithms. IBM J. Res. Dev. 31(2), 249–260 (1987)
Keogh, J.E., Davidson, K.: Data Structures Demystified. McGraw-Hill (2004)
Knuth, D.E., James, H., Morris, J., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6(2), 323–350 (1977)
Manber, U., Myers, E.: Suffix arrays: a new method for on-line string searches. SIAM J. Comput. 22(5), 935–948 (1993)
Mirzaian, A.: Triangulating Simple Polygons: Pseudo-Triangulations. Tech. rep., York University (1988). Tech. report No. CS-88-12
Sedgewick, R., Wayne, K.: Algorithms, 4th edn. Addison-Wesley Professional (2011)
Tamir, A.: An \(O(pn^2)\) algorithm for the \(p\)-median and related problems on tree graphs. Oper. Res. Lett. 19, 59–64 (1996)
Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14(3), 249–260 (1995)
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)
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2013 The Author(s)
About this chapter
Cite this chapter
Forišek, M., Steinová, M. (2013). Strings and Sequences. In: Explaining Algorithms Using Metaphors. SpringerBriefs in Computer Science. Springer, London. https://doi.org/10.1007/978-1-4471-5019-0_4
Download citation
DOI: https://doi.org/10.1007/978-1-4471-5019-0_4
Published:
Publisher Name: Springer, London
Print ISBN: 978-1-4471-5018-3
Online ISBN: 978-1-4471-5019-0
eBook Packages: Computer ScienceComputer Science (R0)