How can I calculate the time compelxity of euclidean distance, which is calculated with this formula:
Well, let's see. How many operations do we have?
n
subtractions (xi - yi)
n
squares of the previousn-1
further additions to add them upSo 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)
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With