What is the computacional complexity in asymptotic notation, O(n) , for the function "pdist2" ?

2 visualizaciones (últimos 30 días)
What is the computacional complexity in asymptotic notation, O(n) , for the function "pdist2" ?

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Jun. de 2017
With a vector of length L, each pair of values has L subtractions, followed by L squaring (each is one multiplication), followed by L-1 additions, followed by one square root. So far this is independent of the number of entries in the matrix, so for any given L, the time is constant.
The number of pairs of distances is N * (N-1) / 2
Therefore pdist2() is O(N^2)

Más respuestas (0)

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by