Meta Interview Question

Implement square root function using basic operations ?

Interview Answers

Anonymous

Jan 2, 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

Anonymous

Nov 3, 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

Anonymous

Apr 17, 2013

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