Skip to content

Category Archives: Divide and Conquer

Divide and Conquer is a type of algorithm which involves breaking down a difficult problem into smaller subproblems, solving the subproblems individually and then merging… Read More
Given an array arr[] of length N consisting of a positive integer, the task is to complete the Q queries and print values accordingly which… Read More
Given m roads and n cars. The cars are numbered from 1 to n. You are also given an array arr[] of size m, each… Read More
Method 1 (Using Nested Loops):We can calculate power by using repeated addition. For example to calculate 5^6. 1) First 5 times add 5, we get 25. (5^2) 2)… 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
Greedy algorithm, divide and conquer algorithm, and dynamic programming algorithm are three common algorithmic paradigms used to solve problems. Here’s a comparison among these algorithms:… Read More
Greedy algorithm and divide and conquer algorithm are two common algorithmic paradigms used to solve problems. The main difference between them lies in their approach… Read More
Given a number n, find the cube root of n.Examples:  Input: n = 3 Output: Cubic Root is 1.442250 Input: n = 8 Output: Cubic… 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: The… Read More
Given a perfect binary tree of height N  and an array of length 2N which represents the values of leaf nodes from left to right.… Read More
Given an array arr[] consisting of N elements(such that N = 2k for some k ≥ 0), the task is to reduce the array and… Read More
Representation Change is one of the variants of the Transfer and Conquer technique where the given problem is transformed into another domain that is more… Read More
Given four arrays A[], B[], C[], D[] and an integer K. The task is to find the number of combinations of four unique indices p,… Read More
Given an array arr[]. The task is to divide arr[] into the maximum number of partitions, such that, those partitions if sorted individually make the… Read More
Given a linked list lis of length N, where N is even. The task is to maximize the sum of two equidistant nodes from the… Read More