C squareRoot calculation


This Content is from Stack Overflow. Question asked by Andreas Steffensen

I needed a square root approximation in C so i looked this post: Squareroot approximation (C) . and got this following implementation:

float x = n;
float y = 1;
float e = 0.001; // Accuracy level
if (n == 0)
    return 0;
while ((x - y) > e)
    x = (x + y) / 2;
    if (n == 0 || x == 0)
        return 0;
    y = n / x;
return x; 

Can anyone help me find the time complexity of this.
And if i have to much strain on the processor?


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?