Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time complexity of euclidean distance

How can I calculate the time compelxity of euclidean distance, which is calculated with this formula:

enter image description here

like image 268
Kaja Avatar asked Jun 19 '14 15:06

Kaja


1 Answers

Well, let's see. How many operations do we have?

  • n subtractions (xi - yi)
  • n squares of the previous
  • n-1 further additions to add them up
  • one square root at the end.

So each of these is (at most) linear in n, and hence so is the whole algorithm. (Assuming that determining the xi and yi are also no worse than O(1).)

like image 167
Andrew Jaffe Avatar answered Sep 29 '22 18:09

Andrew Jaffe