Frage im Vorstellungsgespräch bei Meta

Implement square root function using basic operations ?

Antworten zu Vorstellungsgespräch

Anonym

2. Jan. 2011

The first solution is using binary search from 0 to a that is if a > 1, and if a < 1 then search in the interval 0 to 1 and the second solution is to use Newton Raphson's Method with the iterative formula x[n] = x[n-1] - ((x[n-1]*x[n-1]-a)/(2*x[n-1])) and the initial guess x[0] = a/2 and it will converge faster than the binary search

2

Anonym

3. Nov. 2010

It is a binary search between 0 and given number. I got it that right but I messed up binary search implementation part.

1

Anonym

17. Apr. 2013

http://www.woolor.com/InterviewMitra/97/use-basic-operations-to-create-a-square-root-function