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...@gmail.comwrote:
Simple hash will do it in O(1) but with careful implementation of
getRandomElement to distribute probability
Try
1 2 3
2 4 5
3 4 6
1 2 2 3 3 4 4 5 6
Median 3, median of medians is 4.
On Nov 2, 11:33 am, Anup Ghatage ghat...@gmail.com wrote:
Median of Medians?
On Tue, Nov 1, 2011 at 10:44 PM, Ankuj Gupta ankuj2...@gmail.com wrote:
We have a N X N matrix whose rows and columns are in sorted order.
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
What you need is to recreate the hash, and make your own hash structure like an
array with 2^n elements where 0.9 * 2^n = N where N is the number of real
elements in your structure (use 90% maximum fill factor)
If you use the hash as a dynamic vector with minimum 10% fill factor and max
90%
correction: if P is prime
VM
NSIT, Dwarka
On , vaibhavmitta...@gmail.com wrote:
Use Lucas Theorem is P is prime.
VM
NSIT, Dwarka
On , Dipit Grover dipitgro...@gmail.com wrote:
Thats really cool! Thanks Dave :)
--
You received this message because you are subscribed to the Google
This is a special case of shuffling problem. In shuffling problem we have
to merge k (here k = 3) parts of array such that each kth element is from
the same sub-array and in same order. For eg -
a1 a2 a3 a4 b1 b2 b3 b4 c1 c2 c3 c4 should become = a1 b1 c1 a2 b2 c2 a3
b3 c3 a4 b4 c4.
Usually
Often you can get optimal performance with unusual combinations of
operations by combining data structures. Here you can get O(1) for all
operations by combining a hash table and a bag of pointers in an
array. The hash table references bag elements by index, and the bag
elements point back at hash
any better solution than O(N^2) in worst case?
How do we take advantage of sorting and find in O(N lg N)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
Ques:we have following data from basis of that one can write algo to
generate a automatic offline voting time table
1.population of different region
2.distance between them them
3.security label like[ A(secure),B(a little bit
risky),C(sensitive) ]
4.geographical
Sorry, small mistake in designated index calculation.
It should be k*p2 % (n-1) instead of (k*p2 -1) % (n - 1).
Thanks,
- Ravindra
On Thu, Nov 3, 2011 at 11:37 PM, ravindra patel ravindra.it...@gmail.comwrote:
This is a special case of shuffling problem. In shuffling problem we have
to merge
Lets say i want to calculate (1000C500)%MOD.
*My Code : *
*
*
long long ans=n;
for(int i=1;i=r;i++) {
ans=(ans*(n-i+1))/i;
ans = ans%MOD;
}
But when the ans inside the loop starts exceeding MOD and you take
ans=ans%MOD then you cannot be sure to get the correct
@vikas
ur algo will search for 1st element of 1d in whole 2d array,
on worst case u'll search it in n^2, then search for all 1d elements
in 2d in O(n)
so whole complexity goes to O(n^2 +n)
it can be reduced if we use hashing of 1d array, and count_found
and while searching for 1st element of 1d
Aamir: Check out the thread Modular arithmetic + Combinatorics
recently in this newsgroup.
Dave
On Nov 3, 1:29 pm, Aamir Khan ak4u2...@gmail.com wrote:
Lets say i want to calculate (1000C500)%MOD.
*My Code : *
*
*
long long ans=n;
for(int i=1;i=r;i++) {
I have a doubt in calculating LCA. While calculating LCA of two
nodes, should those two nodes can also be ancestor. As wikipedia
states that
The lowest common ancestor is defined between two nodes v and w as
the lowest node in T that has both v and w as descendants (where we
allow a node to be a
14 matches
Mail list logo