I want to have a set of randomly selected N distinct numbers from {1,2,...(k-1),K} where K>N. I want to write a C program to efficiently do this.
Any help appreciated.
Note:
The naive program is just to generate random number, check whether it has been already generated and if not add it to the list is easy to implement. I was looking for something more efficient as if K and N are comparable then this will be just inefficient computation.