Skip to content

Tag Archives: Binary Search

Binary search is a widely used searching algorithm that requires the array to be sorted before search is applied. The main idea behind this algorithm… Read More
A rational is represented as p/qb, for example 2/3. Given a sorted array of rational numbers, how to search an element using Binary Search. Use… Read More
Given an integer X, find its square root. If X is not a perfect square, then return floor(√x). Examples :  Input: x = 4Output: 2Explanation:… Read More
Given an array of jobs with different time requirements. There are K identical assignees available and we are also given how much time an assignee… Read More
Given a sorted array in which all elements appear twice (one after one) and one element appears only once. Find that element in O(log n)… Read More
Given two sets represented by two arrays, how to check if the given two sets are disjoint or not? It may be assumed that the… Read More
Given a binary array arr[] of size N, which is sorted in non-increasing order, count the number of 1’s in it.  Examples:  Input: arr[] =… Read More
Consider the following C implementation of Binary Search function, is there anything wrong in this?  C // A iterative binary search function. It returns location… Read More
Binary insertion sort is a sorting algorithm which is similar to the insertion sort, but instead of using linear search to find the location where… Read More
We basically ignore half of the elements just after one comparison. Compare x with the middle element. If x matches with middle element, we return… Read More
 Problem: Given a sorted array arr[] of n elements, write a function to search a given element x in arr[] and return the index of… Read More
Given a sorted array arr[] (may be distinct or may contain duplicates) of size N that is rotated at some unknown point, the task is… Read More
Given a function ‘int f(unsigned int x)’ which takes a non-negative integer ‘x’ as input and returns an integer as output. The function is monotonically… Read More
We are aware of the binary search algorithm. Binary search is the easiest algorithm to get right. I present some interesting problems that I collected on… Read More
Given two sorted arrays, a[] and b[], the task is to find the median of these sorted arrays, where N is the number of elements… Read More

Start Your Coding Journey Now!