[algogeeks] Array ques based on correlation factor

2011-09-17 Thread sivaviknesh s
Write a method fill up an array of size n - and returns the array to the caller - with the following conditions 1. the numbers shud be between 0 to n-1 2. no repeated numbers 3. the method should have a deterministic time to fill the arrays 4. arrays returned from the method should have

Re: [algogeeks] Array ques based on correlation factor

2011-09-17 Thread Piyush Grover
=Take a function rand() which returns value between [0, 1) uniformly or use function rand(n) = n*rand() which return value between 0- (n-1) using uniform probability distribution. =Now create a array A[0..n-1] = [0..n-1] now rake an array R. k = n; for(i = 0; i n; i++){ a = rand(k);