simple hash ?
can you specify the hashing function because if we use stl's map its
complexity is O(log(n))

On Thu, Nov 3, 2011 at 1:48 AM, Robert Badita <[email protected]>wrote:

> Simple hash will do it in O(1) but with careful implementation of
> getRandomElement to distribute probability evenly to each bucket / element
> in the bucket
>
>
> On Nov 2, 2011, at 5:52 PM, shady <[email protected]> wrote:
>
> does anyone knows how much is the complexity of operations erase and
> pop_back in case of Vector(STL)
> what would you choose :
>
> Design a data structure where the following 3 functions are optimised:
>
> 1. Insert(n)
> 2. GetRandomElement()
> 3. Remove(n)
>
> Write a class, and implement the functions. Give complexity of each of
> these
>
>
> what would you choose, insertion can always be done in O(1), but what
> about getrandomelement().... if we use simple arrays than for those
>
> 1. -> O(1)
>
> 2. -> O(1)
>
> 3. -> O(n)
>
> --
> 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