Work in HR or Recruiting?
Google
www.google.com Mountain View, CA 5000+ Employees
Work in HR? Complete Your Profile

1,964 interview experiences Back to all Google Interview Questions & Reviews

Interview Question for Software Engineer at Google:
Jul 31, 2012

Write a Square Root function for a computer without floating point calculations


Add Tags [?]

See more for this Google Software Engineer Interview

Helpful Question?  
Yes | No
Inappropriate?

Answers & Comments (4)

2 of 3 people found this helpful

Aug 5, 2012

by Junior:

Perhaps using binary search will work.
Helpful Answer?  
Yes | No
Inappropriate?

Aug 8, 2012

by Claudio:

By approximation.

Star with a = 1 and check if a*a is > N. If so you return a-1 else a++ and move forward.

The fact that here we cannot use the floating point calculation makes everything trivial and not much accurate.

Anyway convert this strategy into an accurate one using floating point it's easy as well.
Helpful Answer?  
Yes | No
Inappropriate?

1 of 1 people found this helpful

Aug 18, 2012

by Don:

Use fractions (=2 integers) and the Babylonian/Newtonian approach:
X(n+1) = (X(n)^2 + N) / (2 * X(n))
Helpful Answer?  
Yes | No
Inappropriate?

3 of 3 people found this helpful

Aug 24, 2012

by Anonymous:

Use the babylonian method
http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
Helpful Answer?  
Yes | No
Inappropriate?

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.