##
Randomized Binary Search Algorithm
June 14, 2017

We are given a sorted array A[] of n elements. We need to find if x is present in A or not.In binary search we… Read More »

June 14, 2017

We are given a sorted array A[] of n elements. We need to find if x is present in A or not.In binary search we… Read More »

June 11, 2017

Given a a of cards, task is to shuffle them. Asked in Amazon Interview Recommended: Please try your approach on {IDE} first, before moving on… Read More »

December 19, 2016

A CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a test to determine whether the user is human or not.… Read More »

August 29, 2016

Given an array of integers, find the most occurring element of the array and return any one of its indexes randomly with equal probability. Examples:… Read More »

August 20, 2016

Given a function rand6() that returns random numbers from 1 to 6 with equal probability, implement one-liner function rand12() using rand6() that returns random numbers… Read More »

August 12, 2016

Given a function rand2() that returns 0 or 1 with equal probability, implement rand3() using rand2() that returns 0, 1 or 2 with equal probability.… Read More »

August 2, 2016

Given a function rand50() that returns 0 or 1 with equal probability, write a function that returns 1 with 75% probability and 0 with 25%… Read More »

May 4, 2016

Conditional Probability Conditional probability P(A | B) indicates the probability of even ‘A’ happening given that the even B happened.

February 28, 2016

We strongly recommend to refer below articles as a prerequisite of this. Randomized Algorithms | Set 1 (Introduction and Analysis) Randomized Algorithms | Set 2… Read More »

November 21, 2015

Given a number n, check if it is prime or not. We have introduced and discussed School method for primality testing in Set 1. Primality… Read More »

November 15, 2015

We strongly recommend to refer below post as a prerequisite of this. Randomized Algorithms | Set 1 (Introduction and Analysis) Classification Randomized algorithms are classified… Read More »

November 13, 2015

What is a Randomized Algorithm? An algorithm that uses random numbers to decide what to do next anywhere in its logic is called Randomized Algorithm..… Read More »

July 7, 2015

We have introduced and discussed below Karger’s algorithm in set 1.

May 24, 2015

Given a singly linked list, select a random node from linked list (the probability of picking a node should be 1/N if there are N… Read More »

May 21, 2015

Given an undirected and unweighted graph, find the smallest cut (smallest number of edges that disconnects the graph into two components).