Abstract
We give subquadratic algorithms that, given two necklaces each with n beads at arbitrary positions, compute the optimal rotation of the necklaces to best align the beads. Here alignment is measured according to the ℓ p norm of the vector of distances between pairs of beads from opposite necklaces in the best perfect matching. We show surprisingly different results for p=1, p even, and p=∞. For p even, we reduce the problem to standard convolution, while for p=∞ and p=1, we reduce the problem to (min,+) convolution and \((\operatorname {median},+)\) convolution. Then we solve the latter two convolution problems in subquadratic time, which are interesting results in their own right. These results shed some light on the classic sorting X+Y problem, because the convolutions can be viewed as computing order statistics on the antidiagonals of the X+Y matrix. All of our algorithms run in o(n 2) time, whereas the obvious algorithms for these problems run in Θ(n 2) time.
Similar content being viewed by others
Notes
“Tropical convolution” would also make sense, by direct analogy with tropical geometry, but we have never seen this terminology used in print.
References
Aloupis, G., Fevens, T., Langerman, S., Matsui, T., Mesa, A., Nuñez, Y., Rappaport, D., Toussaint, G.: Algorithms for computing geometric measures of melodic similarity. J. Comput. Music 30(3), 67–76 (2006)
Ardila, Y.J.P., Clifford, R., Iliopoulos, C.S., Landau, G.M., Mohamed, M.: Necklace swap problem for rhythmic similarity measures. Int. J. Comput. Methods 5(3), 351–363 (2008)
Baran, I., Demaine, E.D., Pǎtraşcu, M.: Subquadratic algorithms for 3SUM. Algorithmica 50(4), 584–596 (2008). Special issue of selected papers from the 9th Workshop on Algorithms and Data Structures, 2005
Bellman, R., Karush, W.: Mathematical programming and the maximum transform. J. Soc. Ind. Appl. Math. 10(3), 550–567 (1962)
Bernstein, D.J.: Fast multiplication and its applications. In: Buhler, J., Stevenhagen, P. (eds.) Algorithmic Number Theory. MSRI Publications, vol. 44 (2008)
Blum, M., Floyd, R.W., Pratt, V., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. J. Comput. Syst. Sci. 7(4), 448–461 (1973)
Bussieck, M., Hassler, H., Woeginger, G.J., Zimmermann, U.T.: Fast algorithms for the maximum convolution problem. Oper. Res. Lett. 15(3), 133–141 (1994)
Cardinal, J., Kremer, S., Langerman, S.: Juggling with pattern matching. Theory Comput. Syst. 39(3), 425–437 (2006)
Chan, T.M.: All-pairs shortest paths with real weights in O(n 3/logn) time. Algorithmica 50, 236–243 (2008)
Chan, T.M.: More algorithms for all-pairs shortest paths in weighted graphs. SIAM J. Comput. 39, 2075–2089 (2010)
Clifford, P., Clifford, R.: Self-normalised distance with don’t cares. In: Ma, B., Zhang, K. (eds.) Combinatorial Pattern Matching. Lecture Notes in Computer Science, vol. 4580, pp. 63–70. Springer, Berlin (2007)
Clifford, P., Clifford, R.: Simple deterministic wildcard matching. Inf. Process. Lett. 101(2), 53–54 (2007)
Clifford, P., Clifford, R., Iliopoulos, C.: Fourier transform methods for δ and (δ,γ) matching and other measures of string similarity. Tech. Rep. TR-04-09, King’s College, London (2004)
Clifford, P., Clifford, R., Iliopoulos, C.: Faster algorithms for δ, γ-matching and related problems. In: Combinatorial Pattern Matching. Lecture Notes in Computer Science, vol. 3537, pp. 71–90. Springer, Berlin (2005)
Cohn, H., Kleinberg, R., Szegedy, B., Umans, C.: Group-theoretic algorithms for matrix multiplication. In: Proceedings of the 46th Annual IEEE Symposium on Foundations of Computer Science, pp. 379–388 (2005)
Colannino, J., Damian, M., Hurtado, F., Iacono, J., Meijer, H., Ramaswami, S., Toussaint, G.: An O(nlogn)-time algorithm for the restriction scaffold assignment. J. Comput. Biol. 13(4), 979–989 (2006)
Cole, R., Hariharan, R.: Verifying candidate matches in sparse and wildcard matching. In: Proceedings of the 34th Annual ACM Symposium on Theory of Computing, Montréal, Canada, pp. 592–601 (2002)
Cooley, J.W., Tukey, J.W.: An algorithm for the machine calculation of complex Fourier series. Math. Comput. 19, 297–301 (1965)
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 2nd edn. MIT Press, Cambridge (2001)
Demaine, E.D., Mitchell, J.S.B., O’Rourke, J.: Problem 41: Sorting X+Y (pairwise sums). In: The Open Problems Project (2006). http://cs.smith.edu/~orourke/TOPP/P41.html
Demaine, E.D., O’Rourke, J.: Open problems from CCCG 2005. Proceedings of the 18th Canadian Conference on Computational Geometry, Kingston, Canada (2006)
Díaz-Báñez, J.M., Farigu, G., Gómez, F., Rappaport, D., Toussaint, G.T.: El compás flamenco: a phylogenetic analysis. In: Proceedings of BRIDGES: Mathematical Connections in Art, Music, and Science, Winfield, KS, pp. 61–70 (2004)
Erickson, J.: Lower bounds for linear satisfiability problems. Chic. J. Theor. Comput. Sci. 8 (1999)
Felzenszwalb, P.F., Huttenlocher, D.P.: Distance transforms of sampled functions. Tech. Rep. TR2004-1963, Faculty of Computing and Information Science, Cornell University (2004)
Fischer, M.J., Paterson, M.S.: String-matching and other products. In: Complexity of computation. SIAM-AMS Proceedings, vol. VII, pp. 113–125. Am. Math. Soc., New York (1974)
Frederickson, G.N., Johnson, D.B.: The complexity of selection and ranking in X+Y and matrices with sorted columns. J. Comput. Syst. Sci. 24(2), 197–208 (1982)
Fredman, M.L.: How good is the information theory bound in sorting? Theor. Comput. Sci. 1(4), 355–361 (1976)
Fredman, M.L.: New bounds on the complexity of the shortest path problem. SIAM J. Comput. 5(1), 83–89 (1976)
Gauss, C.F.: Werke, vol. 3. Königlichen Gesellschaft der Wissenschaften, Göttingen (1866)
Heideman, M.T., Johnson, D.H., Burrus, C.S.: Gauss and the history of the fast Fourier transform. Arch. Hist. Exact Sci. 34(3), 265–277 (1985)
Indyk, P.: Faster algorithms for string matching problems: Matching the convolution bound. In: Proceedings of the 39th Annual Symposium on Foundations of Computer Science, Palo Alto, CA, pp. 166–173 (1998)
Kalai, A.: Efficient pattern-matching with don’t cares. In: Proceedings of the 13th Annual ACM-SIAM Symposium on Discrete Algorithms, San Francisco, CA, pp. 655–656 (2002)
Maragos, P.: Differential morphology. In: Mitra, S., Sicuranza, G. (eds.) Nonlinear Image Processing, pp. 289–329. Academic Press, New York (2000)
Moreau, J.J.: Inf-convolution, sous-additivité, convexité des fonctions numériques. J. Math. Pures Appl., Neuv. Sér. 49, 109–154 (1970)
Rockafellar, R.T.: Convex Analysis. Princeton Mathematical Series. Princeton University Press, Princeton (1970)
Schönhage, A., Paterson, M., Pippenger, N.: Finding the median. J. Comput. Syst. Sci. 13(2), 184–199 (1976)
Steiger, W.L., Streinu, I.: A pseudo-algorithmic separation of lines from pseudo-lines. Inf. Process. Lett. 53(5), 295–299 (1995)
Strömberg, T.: The operation of infimal convolution. Diss. Math. 352, 58 (1996)
Toussaint, G.: The geometry of musical rhythm. In: Revised Papers from the Japan Conference on Discrete and Computational Geometry, Tokyo, Japan. Lecture Notes in Computer Science, vol. 3742, pp. 198–212 (2004)
Toussaint, G.T.: A comparison of rhythmic similarity measures. In: Proceedings of the 5th International Conference on Music Information Retrieval, Barcelona, Spain, pp. 242–245 (2004) A longer version appears as Technical Report SOCS-TR-2004.6, School of Computer Science, McGill University, August 2004
Acknowledgements
This work was initiated at the 20th Bellairs Winter Workshop on Computational Geometry held January 28–February 4, 2005. We thank the other participants of that workshop—Greg Aloupis, Justin Colannino, Mirela Damian-Iordache, Vida Dujmović, Francisco Gomez-Martin, Danny Krizanc, Erin McLeish, Henk Meijer, Patrick Morin, Mark Overmars, Suneeta Ramaswami, David Rappaport, Diane Souvaine, Ileana Streinu, David Wood, Godfried Toussaint, Remco Veltkamp, and Sue Whitesides—for helpful discussions and contributing to a fun and creative atmosphere. We particularly thank the organizer, Godfried Toussaint, for posing the problem to us. The last author would also like to thank Luc Devroye for pointing out the easy generalization of the ℓ 2 necklace alignment problem to ℓ p for any fixed even integer p.
Author information
Authors and Affiliations
Corresponding author
Additional information
In memory of our colleague Mihai Pǎtraşcu.
D. Bremner and T.M. Chan are supported by NSERC. E.D. Demaine and J. Iacono are supported in part by NSF grants CCF-0430849 and OISE-0334653 and by an Alfred P. Sloan Fellowship. F. Hurtado is supported in part by projects MICINN MTM2009-07242, Gen. Cat. DGR 2009SGR1040, and ESF EUROCORES programme EuroGIGA, CRP ComPoSe: MICINN Project EUI-EURC-2011-4306, for Spain.
Rights and permissions
About this article
Cite this article
Bremner, D., Chan, T.M., Demaine, E.D. et al. Necklaces, Convolutions, and X+Y . Algorithmica 69, 294–314 (2014). https://doi.org/10.1007/s00453-012-9734-3
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00453-012-9734-3