跳至主要内容

博文

目前显示的是 十二月, 2013的博文

Square root of a number (sqrt)

For many technical interviews in big companies, one question might be asked frequently, which is how to compute a number's square root. Based on my experience, Yahoo and Linkedin interviewers like it in the first phone screen.  It looks so simple that many people would neglect some nature behind its appearance. In my blog, I will focus on the analysis part and spend some time on testing because I believe that people can not give perfect coding solution without solid analysis and sound testing cases. Let's get into it. Problem description Given you a number, compute its square root. Analysis 1) Before we start, we have to truly and totally understand what the meaning of the problem is. More importantly, in the interview process, we should know what method or technology the interviewers want us to show to them. So ask them conditions in the problem to clear ambiguities. In this case, what kind of number is as the input, integer or float? Is it a perfect square root problem?