[algogeeks] random number [a....b]

2009-10-05 Thread gold007
how can we generate random values which lie in the range [a,b] or wrire a function for the same --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge

[algogeeks] Re: Good problem

2009-10-05 Thread Bharath
Can you please make question a bit clear. What does minimum distance between any two points. Do u mean sum of minimum distance? On Mon, Oct 5, 2009 at 7:52 PM, monty 1987 <1986mo...@gmail.com> wrote: > We have to locate n points on the x-axis > For each point xi > the

[algogeeks] Good problem

2009-10-05 Thread monty 1987
We have to locate n points on the x-axis For each point xi the x co-ordinate of it lies between a range [r1i,r2i] Now we have to decide the location of points such that minimum { distance between any two points } is maximum. Any answer is welcomed. --~--~-

[algogeeks] Re: Array Repeated Element O(n)

2009-10-05 Thread BalaMurugan Kannan
If the array is sorted, doing xor of a[n] and a[n+] will result 0 for duplicate no. --Bala On Mon, Oct 5, 2009 at 7:06 PM, Ramaswamy R wrote: > Use a bit-field of M bits to keep track of the presence of X..X+M-1. We can > do 2^32/M passes (if the elements are 32-bit size) to check for numbers i

[algogeeks] Re: Array Repeated Element O(n)

2009-10-05 Thread Ramaswamy R
Use a bit-field of M bits to keep track of the presence of X..X+M-1. We can do 2^32/M passes (if the elements are 32-bit size) to check for numbers in a range. Depending on the memory footprint and speed the app would want we can find a soft spot for X. On Sun, Oct 4, 2009 at 9:39 PM, Amit Chandak

[algogeeks] Re: Array Repeated Element O(n)

2009-10-05 Thread sharad kumar
hi hw about this for(i=0;iwrote: > > Hi Friends, > Given an array in which all the elements are unique except one element > which occurs 'twice'. How can we find this repeated element in O(n) > time and constant space? > > Regards, > Amit. > > > > --~--~-~--~~~---~--~-

[algogeeks] Re: simple random number generator

2009-10-05 Thread Prabhu Hari Dhanapal
i tried the algorithm with a very simple C program and this is the output i got , from my visual inspection , there was no repetition for the first 98 values after which the cycle started again, this is my output followed by a simple implementation. Hope this helps pdhan...@hansolo:/afs/ece.cmu

[algogeeks] Re: simple random number generator

2009-10-05 Thread Prabhu Hari Dhanapal
hi , I think the Linear Congruential Generator is believed to be the most simple of all PRNGs. The sequence can be generated using the following, X(n+1) = (a* Xn +c ) mod m In the above , your first step would be X1 = (a*X0 +c ) mod m X0 is the seed value that you need to feed to the algorithm

[algogeeks] Array Repeated Element O(n)

2009-10-05 Thread Amit Chandak
Hi Friends, Given an array in which all the elements are unique except one element which occurs 'twice'. How can we find this repeated element in O(n) time and constant space? Regards, Amit. --~--~-~--~~~---~--~~ You received this message because you are subscribe