Solution: using newton method:
Solving f(x) = 0, using iterative method: x_1 = x_0  f(x_0) / f'(x_0).
So the iterative for sqrt(n) is
y = x/2 + N/(2x)
Implementation:
x = 2^ceil(numbits(N)/2)
loop:
y = floor((x + floor(N/x))/2)
if y >= x
return x
x = y
Tuesday, March 19, 2013
Subscribe to:
Post Comments (Atom)
Manacher's Longest Palindromic Substring Algorithm
http://manacherviz.s3websiteuseast1.amazonaws.com/#/

Imaging you are a 40 years' old truck driver living in Illinois. You have a wonderful family and two beautiful kids. You loan a...

Given n nonnegative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap aft...

The total INCOME of one BEST Chinese doctor is much SMALLER than the TAX paid of one WORST US doctor. One Chinese do...
No comments:
Post a Comment