@techcoder

Making an array of 32768 or INT_MAX will make ur compiler cry

Also ur case doesnt handle the scenario where square root is a decimal
number



On Tue, Aug 30, 2011 at 1:35 PM, tech coder <[email protected]>wrote:

> 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 <[email protected]> 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to