gravatar

Blog # 42 : Random Selection from a Linked List


Random Selection from a Linked List There is a linked list of numbers of length N. N is very large and you don’t know N. You have to write a function that will return k random numbers from the list. Numbers should be completely random. 
Conditions : 
  1. Use random number function rand() that returns a number between 0 and 1.
  2. It must be done in O(N) time
p.s. - For Remarks please hit the question name once, given in the question itself. For Hint, hit it twice and for the solution, hit it thrice.