@ WgpShashank :
considering your latest comment abt you algo...
/*
i didn't get how my approach will fail , can u check for the exmple u said
? if u sum the 1st array using 2 as base then sum will be 3 (*exculding 2 ,
although it won't metter* ) , then u search that elemnt in 2nd array , u
won;t find & u return -1 , say these array are not similer
*/
arr[]={2,0,0,0}; //considering base 2 (btw u didnt tell in your algo how
base are selected....its random selection or arr[0] or max or min in that
array)
for i=1 to n
sum1+=2^arr[i];
sum1=3;
/*
Now sort the 2nd array O(mlogm) , find the number which we have taken as
base in 1st array , it will take O(logm) binary search
now calculate the sum of all the remaining elements with base we found
(base has to be same) as 2nd array has 3 , we found base as 3 here as well.
*/
as highlighted above , copied from your first post.
base = 2;
again i am excluding base i.e base=2 in 2nd array.
say sum2 and sum1 were int type.
arr2[]={2,-2,1,0};
for i=1 to n
sum2+=2^arr[i];
sum2=3;
sum1=sum2 // correct , which is not true.
now if you say you are considering sum1 and sum2 float type.
how far we need to check for precision , suppose same array has
arr2={2,-9000,1,0};
again if base selected is large say 900 .......then same would fail again.
i guess you understood my concern , taking pow(a,b) , where b can be -ve
could hurt your logic.
correct me if i am wrong.
On Mon, Jan 9, 2012 at 5:12 PM, WgpShashank <[email protected]>wrote:
> @sravan i didn't get how my approach will fail , can u check for the
> exmple u said ? if u sum the 1st array using 2 as base then sum will be 3
> (exculding 2 , although it won't metter ) , then u search that elemnt in
> 2nd array , u won;t find & u return -1 , say these array are not similer .
>
>
> correct me if i got wrong ?
>
>
> Thanks
> Shashank Mani
> Computer Science
> Birla Institute of Technology,Mesra
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/6DQ6oKWebh4J.
>
> 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.