the sqrt of 32 bit number can't be more than 16 bits.

have an array of 2^16 elemnts wtih elemts 1 2 3 4 5 .... 32768 .

now apply binary search
i=a[mid]    where mid=(lower+upper)/2

if(i*i==num)
i is the sqrt

increment lower and upper accordingly as we do in binary search

so order is Ologn    where n=2^16

On Tue, Aug 30, 2011 at 11:37 AM, Raghavan <its...@gmail.com> wrote:

> how to design this logic effectively?
>
> double squareRoot(int num){
>
> }
>
>
>
> --
> Thanks and Regards,
> Raghavan KL
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to