# Category - Randomized Algorithms

## Java Programming – K’th Smallest/Largest Element in Unsorted Array Expected Linear Time

Given an array and a number k where k is smaller than size of array, we need to find the k’th smallest element in the given array.

## C++ Programming – K’th Smallest/Largest Element in Unsorted Array Expected Linear Time

Given an array and a number k where k is smaller than size of array, we need to find the k’th smallest element in the given array.

## C Programming – K’th Smallest/Largest Element in Unsorted Array Expected Linear Time

Given an array and a number k where k is smaller than size of array, we need to find the k’th smallest element in the given array.

## C Programming – Reservoir Sampling

Reservoir sampling is a family of randomized algorithms for randomly choosing k samples from a list of n items, where n is either a very large.

## C Programming – Shuffle a given array

Given an array, write a program to generate a random permutation of array elements. This question is also asked as “shuffle a deck of cards” or “randomize a...

## Python Programming – Select a Random Node from a Singly Linked List

The idea is to use Reservoir Sampling. Following are the steps. This is a simpler version of Reservoir Sampling as we need to select only one key.

## Java Programming – Select a Random Node from a Singly Linked List

The idea is to use Reservoir Sampling. Following are the steps. This is a simpler version of Reservoir Sampling as we need to select only one key.

## C Programming – Select a Random Node from a Singly Linked List

The idea is to use Reservoir Sampling. Following are the steps. This is a simpler version of Reservoir Sampling as we need to select only one key.

## Java Programming – Randomized Algorithms (1/2) Approximate Median

It is quite easy to visualize this statement since the median which we report will be (k/2)th element and if we take k/2 elements from the left quarter.

## C Programming – Randomized Algorithms (1/2) Approximate Median

It is quite easy to visualize this statement since the median which we report will be (k/2)th element and if we take k/2 elements from the left quarter.