On 8/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> 1 #include <stdio.h>
> 2
> 3 int main() {
> 4
> 5 int A[] = {8,5,4,2,9}, B[] = {1,2,3,4,6};
> 6 static int fo[10] ,i,ret = 0 ; /* max value is stored in A
> which is 9
> 7 if we wouldn't know this, we'd
> nee to rely
> 8 on INT_MAX or some other shit */
> 9
> 10 for (i = 0; i < 5; i++)
> 11 fo[A[i]] = 1;
> 12
> 13 for (i = 0; i < 5; i++)
> 14 if (fo[B[i]])
> 15 ++ret;
> 16
> 17 return printf("%d\n" , ret);
> 18 }
>
> Just out of couriostiy... What's the complexity of the above code?
> O(2n) ?
Memory: O(MAXINT)
Time: O(n+m)
Where MAXINT is maximum possible element of array,
n and m, sizes of arrays
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---