@Harshal...it aint O(n)...initiaize all elemnts of aux to 0. This can be
even o(n^2) depending on the range....

On Sat, Oct 16, 2010 at 12:06 AM, Harshal <[email protected]> wrote:

> let arr is given array of size N.
>
> find the max_number in arr. O(n)
>
> form an aux array of size_max
>
> initiaize all elemnts of aux to 0. O(n)
>
> for(i=0;i<N;i++)    O(n)
> if(aux[arr[i]]>0)
> return arr[i];             //duplicate element
> else
> aux[arr[i]]=i+1;
>
> the solution requires extra memory.
>
> pls correct me if i am wrong.
>
> --
> 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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
S.Nishaanth,
Computer Science and engineering,
IIT Madras.

-- 
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