# Category Archives: Divide and Conquer

## Frequency of an integer in the given array using Divide and Conquer

Given an unsorted array arr[] and an integer K, the task is to count the occurrences of K in the given array using Divide and… Read More »

## Median of an unsorted array using Quick Select Algorithm

Given an unsorted array arr[] of length N, the task is to find the median of of this array. Median of a sorted array of… Read More »

## Count of smaller elements on right side of each element in an Array using Merge sort

Given an array arr[] of N integers, the task is to count the number of smaller elements on the right side for each of the… Read More »

## Floyd-Rivest Algorithm

The Floyd-Rivest algorithm is a selection algorithm used to find the kth smallest element in an array of distinct elements. It is similar to the… Read More »

## Sorting Algorithm Visualization : Merge Sort

The human brain can easily process visuals instead of long codes to understand the algorithms. In this article, a program that program visualizes the Merge… Read More »

## Minimum K such that sum of array elements after division by K does not exceed S

Given an array arr[] of N elements and an integer S. The task is to find the minimum number K such that the sum of… Read More »

## Expected number of moves to reach the end of a board | Matrix Exponentiation

Given a linear board of length N numbered from 1 to N, the task is to find the expected number of moves required to reach… Read More »

## Place the prisoners into cells to maximize the minimum difference between any two

Given an array cell[] of N elements, which represent the positions of the cells in a prison. Also, given an integer P which is the… Read More »

## Find N in the given matrix that follows a pattern

Given an infinite matrix filled with the natural numbers as shown below: 1 2 4 7 . . . 3 5 8 . . .… Read More »

## Find the count of distinct numbers in a range

Given an array of size N containing numbers only from 0 to 63, and you are asked Q queries regarding it. Queries are as follows:… Read More »

## Smallest subarray with GCD as 1 | Segment Tree

Given an array arr[], the task is to find the smallest sub-arrays with GCD equal to 1. If there is no such sub-array then print… Read More »

## Significant Inversions in an Array

Given an array arr[], the task is to finds the total significant inversion count for the array. Two elements arr[i] and arr[j] form a significant… Read More »

## Find an N x N grid whose xor of every row and column is equal

Given an integer N which is a multiple of 4, the task is to find an N x N grid for which the bitwise xor… Read More »

## Modular Exponentiation of Complex Numbers

Given four integers A, B, K, M. The task is to find (A + iB)K % M which is a complex number too. A +… Read More »

## Cost Based Tower of Hanoi

The standard Tower of Hanoi problem is explained here . In the standard problem, all the disc transactions are considered identical. Given a 3×3 matrix… Read More »