If McDonalds were run like a software company, one out of every hundred Big Macs would give you food poisoning, and the response would be, ‘We’re sorry, here’s a coupon for two more.’ “ Mark Minasi

Reservoir Sampling

Language Java | Level Intermediate | Category Algorithms | August 5, 2015 9:15 am

Algorithm Problem Description

Reservoir sampling is a family of randomized algorithms for randomly choosing a sample of k items from a list S containing n items, where n is either a very large or unknown number.

Retrieve k random numbers from an array of the undetermined size we use a technique called reservoir sampling. Write a program to display the random strings from the given file?



Print the file content using  Reservoir Sampling

import java.util.List;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;



Please login to add comments.