Re: [algogeeks] Re: Median of 2D matrix

2011-11-06 Thread Robert Badita
It's the wrong diagonal and that algo still holds until another example. btw I think if the median of the sorted matrix is the median of the second diagonal then you have found a stable algorithm to find the median of any array by sorting rows and columns in O(2 sqrt N * sqrt N * log sqrt N) =

Re: [algogeeks] Designing Data Structure

2011-11-03 Thread Robert Badita
The hash function is the middle n bits of x * scramble, choosing the lowest n bits has bad hasing properties On Nov 3, 2011, at 1:59 PM, Robert Badita robert.bad...@gmail.com wrote: What you need is to recreate the hash, and make your own hash structure like an array with 2^n elements where

Re: [algogeeks] Designing Data Structure

2011-11-03 Thread Robert Badita
x is your element to be hashed. - multiplicative hashing On Nov 3, 2011, at 1:09 PM, shady sinv...@gmail.com wrote: 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 robert.bad

Re: [algogeeks] Designing Data Structure

2011-11-02 Thread Robert Badita
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 sinv...@gmail.com wrote: does anyone knows how much is the complexity of operations erase and pop_back