Open In App

Decrease and Conquer

Last Updated : 15 Feb, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

As divide-and-conquer approach is already discussed, which include following steps: Divide the problem into a number of subproblems that are smaller instances of the same problem. Conquer the sub problems by solving them recursively. If the subproblem sizes are small enough, however, just solve the sub problems in a straightforward manner. Combine the solutions to the sub problems into the solution for the original problem. Similarly, the approach decrease-and-conquer works, it also include following steps: Decrease or reduce problem instance to smaller instance of the same problem and extend solution. Conquer the problem by solving smaller instance of the problem. Extend solution of smaller instance to obtain solution to original problem . Basic idea of the decrease-and-conquer technique is based on exploiting the relationship between a solution to a given instance of a problem and a solution to its smaller instance. This approach is also known as incremental or inductive approach.

Decrease and conquer is a technique used to solve problems by reducing the size of the input data at each step of the solution process. This technique is similar to divide-and-conquer, in that it breaks down a problem into smaller subproblems, but the difference is that in decrease-and-conquer, the size of the input data is reduced at each step. The technique is used when it’s easier to solve a smaller version of the problem, and the solution to the smaller problem can be used to find the solution to the original problem.

  1. Some examples of problems that can be solved using the decrease-and-conquer technique include binary search, finding the maximum or minimum element in an array, and finding the closest pair of points in a set of points.
  2. The main advantage of decrease-and-conquer is that it often leads to efficient algorithms, as the size of the input data is reduced at each step, reducing the time and space complexity of the solution. However, it’s important to choose the right strategy for reducing the size of the input data, as a poor choice can lead to an inefficient algorithm.

“Divide-and-Conquer” vs “Decrease-and-Conquer”:

As per Wikipedia, some authors consider that the name “divide and conquer” should be used only when each problem may generate two or more subproblems. The name decrease and conquer has been proposed instead for the single-subproblem class. According to this definition, Merge Sort and Quick Sort comes under divide and conquer (because there are 2 sub-problems) and Binary Search comes under decrease and conquer (because there is one sub-problem).

Implementations of Decrease and Conquer :

This approach can be either implemented as top-down or bottom-up. Top-down approach : It always leads to the recursive implementation of the problem. Bottom-up approach : It is usually implemented in iterative way, starting with a solution to the smallest instance of the problem.

Variations of Decrease and Conquer :

There are three major variations of decrease-and-conquer:

  1. Decrease by a constant
  2. Decrease by a constant factor
  3. Variable size decrease

Decrease by a Constant : In this variation, the size of an instance is reduced by the same constant on each iteration of the algorithm. Typically, this constant is equal to one , although other constant size reductions do happen occasionally. Below are example problems :

Decrease by a Constant factor: This technique suggests reducing a problem instance by the same constant factor on each iteration of the algorithm. In most applications, this constant factor is equal to two. A reduction by a factor other than two is especially rare. Decrease by a constant factor algorithms are very efficient especially when the factor is greater than 2 as in the fake-coin problem. Below are example problems :

Variable-Size-Decrease : In this variation, the size-reduction pattern varies from one iteration of an algorithm to another. As, in problem of finding gcd of two number though the value of the second argument is always smaller on the right-handside than on the left-hand side, it decreases neither by a constant nor by a constant factor. Below are example problems :

There may be a case that problem can be solved by decrease-by-constant as well as decrease-by-factor variations, but the implementations can be either recursive or iterative. The iterative implementations may require more coding effort, however they avoid the overload that accompanies recursion. Reference : Anany Levitin Decrease and conquer

Advantages of Decrease and Conquer:

  1. Simplicity: Decrease-and-conquer is often simpler to implement compared to other techniques like dynamic programming or divide-and-conquer.
  2. Efficient Algorithms: The technique often leads to efficient algorithms as the size of the input data is reduced at each step, reducing the time and space complexity of the solution.
  3. Problem-Specific: The technique is well-suited for specific problems where it’s easier to solve a smaller version of the problem.

Disadvantages of Decrease and Conquer:

  1. Problem-Specific: The technique is not applicable to all problems and may not be suitable for more complex problems.
  2. Implementation Complexity: The technique can be more complex to implement when compared to other techniques like divide-and-conquer, and may require more careful planning.

Reference Book:

“Introduction to Algorithms” by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein is a classic textbook that covers the basics of algorithms, including the decrease-and-conquer technique. This book provides a comprehensive overview of algorithms and is a useful resource for students and professionals interested in the field of computer science.


Previous Article
Next Article

Similar Reads

Fibonacci Heap - Deletion, Extract min and Decrease key
In the last post, we discussed the Insertion and Union of Fibonacci Heaps. In this post, we will discuss Extract_min(), Decrease_key() and Deletion() operations on Fibonacci heap. Prerequisites: Fibonacci Heap (Introduction) Fibonacci Heap - Insertion and Union Extract_min(): We create a function for deleting the minimum node and setting the min po
12 min read
How to implement decrease key or change key in Binary Search Tree?
Given a Binary Search Tree, write a function that takes the following three as arguments: Root of tree Old key value New Key Value The function should change old key value to new key value. The function may assume that old key-value always exists in Binary Search Tree. Example: Input: Root of below tree 50 / \ 30 70 / \ / \ 20 40 60 80 Old key valu
15+ min read
Difference between Greedy Algorithm and Divide and Conquer Algorithm
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 to solving problems. Greedy Algorithm:The greedy algorithm is an algorithmic paradigm that follows the problem-solving heuristic of making the locally optimal choice at each stage wit
3 min read
Comparison among Greedy, Divide and Conquer and Dynamic Programming algorithm
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: Approach:Greedy algorithm: Makes locally optimal choices at each step with the hope of finding a global optimum.Divide and conquer algorithm: Breaks down a probl
4 min read
Search in a Row-wise and Column-wise Sorted 2D Array using Divide and Conquer algorithm
Given an n x n matrix, where every row and column is sorted in increasing order. Given a key, how to decide whether this key is in the matrix. A linear time complexity is discussed in the previous post. This problem can also be a very good example for divide and conquer algorithms. Following is divide and conquer algorithm.1) Find the middle elemen
15+ min read
Advantages and Disadvantages of Divide and Conquer Algorithms
Divide and Conquer is an algorithmic paradigm in which the problem is solved using the Divide, Conquer, and Combine strategy. A typical divide-and-conquer algorithm solves a problem using the following three steps: Divide: This involves dividing the problem into smaller sub-problems.Conquer: Solve sub-problems by calling recursively until solved.Co
2 min read
Closest Pair of Points using Divide and Conquer algorithm
We are given an array of n points in the plane, and the problem is to find out the closest pair of points in the array. This problem arises in a number of applications. For example, in air-traffic control, you may want to monitor planes that come too close together, since this may indicate a possible collision. Recall the following formula for dist
15+ min read
Advanced master theorem for divide and conquer recurrences
The Master Theorem is a tool used to solve recurrence relations that arise in the analysis of divide-and-conquer algorithms. The Master Theorem provides a systematic way of solving recurrence relations of the form: T(n) = aT(n/b) + f(n) where a, b, and f(n) are positive functions and n is the size of the problem. The Master Theorem provides conditi
5 min read
Dynamic Programming vs Divide-and-Conquer
In this article I’m trying to explain the difference/similarities between dynamic programming and divide and conquer approaches based on two examples: binary search and minimum edit distance (Levenshtein distance).The ProblemWhen I started to learn algorithms it was hard for me to understand the main idea of dynamic programming (DP) and how it is d
12 min read
Merge K sorted arrays | Set 3 ( Using Divide and Conquer Approach )
Giving k sorted arrays, each of size N, the task is to merge them into a single sorted array. Examples: Input: arr[][] = {{5, 7, 15, 18}, {1, 8, 9, 17}, {1, 4, 7, 7}} Output: {1, 1, 4, 5, 7, 7, 7, 8, 9, 15, 17, 18} Input: arr[][] = {{3, 2, 1} {6, 5, 4}} Output: {1, 2, 3, 4, 5, 6} Prerequisite: Merge SortSimple Approach: A simple solution is to appe
15+ min read
Merge K sorted arrays of different sizes | ( Divide and Conquer Approach )
Given k sorted arrays of different length, merge them into a single array such that the merged array is also sorted.Examples: Input : {{3, 13}, {8, 10, 11} {9, 15}} Output : {3, 8, 9, 10, 11, 13, 15} Input : {{1, 5}, {2, 3, 4}} Output : {1, 2, 3, 4, 5} Let S be the total number of elements in all the arrays.Simple Approach: A simple approach is to
8 min read
Sum of maximum of all subarrays | Divide and Conquer
Given an array arr[] of length N, the task is to find the sum of the maximum elements of every possible sub-array of the array.Examples: Input : arr[] = {1, 3, 1, 7} Output : 42 Max of all sub-arrays: {1} - 1 {1, 3} - 3 {1, 3, 1} - 3 {1, 3, 1, 7} - 7 {3} - 3 {3, 1} - 3 {3, 1, 7} - 7 {1} - 1 {1, 7} - 7 {7} - 7 1 + 3 + 3 + 7 + 3 + 3 + 7 + 1 + 7 + 7 =
12 min read
Divide and Conquer Optimization in Dynamic Programming
Dynamic programming (DP) is arguably the most important tool in a competitive programmer's repertoire. There are several optimizations in DP that reduce the time complexity of standard DP procedures by a linear factor or more, such as Knuth's optimization, Divide and Conquer optimization, the Convex Hull Trick, etc. They are, of paramount importanc
15+ min read
Transform and Conquer Technique
The Transform and conquer technique is a way of solving problems by breaking them down into smaller subproblems, solving the smaller subproblems, and then combining the solutions to the subproblems to solve the original problem. This technique can be used to solve problems in many different areas, including mathematics, computer science, and engine
5 min read
Divide and Conquer definition & meaning in DSA
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 the solutions of those subproblems to solve the actual problem. Properties of Divide and Conquer:Divides the problem into smaller subproblems.Each subproblem is solved independent
2 min read
Problem Reduction in Transform and Conquer Technique
What is Problem Reduction?Problem reduction is an algorithm design technique that takes a complex problem and reduces it to a simpler one. The simpler problem is then solved and the solution of the simpler problem is then transformed to the solution of the original problem. Problem reduction is a powerful technique that can be used to simplify comp
7 min read
Maximum Subarray Sum using Divide and Conquer algorithm
You are given a one dimensional array that may contain both positive and negative integers, find the sum of contiguous subarray of numbers which has the largest sum. For example, if the given array is {-2, -5, 6, -2, -3, 1, 5, -6}, then the maximum subarray sum is 7 (see highlighted elements). Recommended: Please solve it on “PRACTICE ” first, befo
12 min read
Divide and Conquer | Set 5 (Strassen's Matrix Multiplication)
Given two square matrices A and B of size n x n each, find their multiplication matrix. Naive Method: Following is a simple way to multiply two matrices. C/C++ Code void multiply(int A[][N], int B[][N], int C[][N]) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { C[i][j] = 0; for (int k = 0; k < N; k++) { C[i][j] += A[i][k]*B[
15+ min read
Tiling Problem using Divide and Conquer algorithm
Given a n by n board where n is of form 2k where k >= 1 (Basically n is a power of 2 with minimum value as 2). The board has one missing cell (of size 1 x 1). Fill the board using L shaped tiles. A L shaped tile is a 2 x 2 square with one cell of size 1x1 missing. Figure 1: An example inputThis problem can be solved using Divide and Conquer. Bel
15+ min read
Longest Common Prefix using Divide and Conquer Algorithm
Given a set of strings, find the longest common prefix. Examples: Input : {“geeksforgeeks”, “geeks”, “geek”, “geezer”} Output : "gee" Input : {"apple", "ape", "april"} Output : "ap" We have discussed word by word matching and character by character matching algorithms.In this algorithm, a divide and conquer approach is discussed. We first divide th
7 min read
Master Theorem For Subtract and Conquer Recurrences
Master theorem is used to determine the Big - O upper bound on functions which possess recurrence, i.e which can be broken into sub problems. Master Theorem For Subtract and Conquer Recurrences: Let T(n) be a function defined on positive n as shown below: for some constants c, a>0, b>0, k>=0 and function f(n). If f(n) is O(nk), then1. If a
3 min read
Convex Hull using Divide and Conquer Algorithm
In computational geometry, a convex hull is the smallest convex polygon that contains a given set of points. It is a fundamental concept with applications in various fields such as computer graphics, robotics, and image processing. Importance of Convex Hull:Convex hulls are important in computational geometry for several reasons: Collision detectio
15 min read
Divide and Conquer in Python
Divide and Conquer is an effective approach for managing challenges that divides a major problem into smaller, easier-to-manage subproblems. The solution to the main problem is obtained by combining the final solutions from multiple individually solved subproblems. This approach works especially well with issues that naturally break down into diffe
3 min read
Representation Change in Transform and Conquer Technique
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 familiar or simpler to execute. In the case of representation change, the instance of a given problem is transformed into another representation without affecting the original instance. Character
8 min read
Instance Simplification Method in Transform and Conquer Technique
Instance simplification is one of the Transform and Conquer techniques. To understand Instance Simplification, first let us understand what is transform and conquer. Transform and Conquer is a technique whose main idea is to transfer the problem into some easier or similar versions using some procedure and then solve that easier or simpler versions
9 min read
Karatsuba algorithm for fast multiplication using Divide and Conquer algorithm
Given two binary strings that represent value of two integers, find the product of two strings. For example, if the first bit string is "1100" and second bit string is "1010", output should be 120. For simplicity, let the length of two strings be same and be n. A Naive Approach is to follow the process we study in school. One by one take all bits o
15+ min read
Divide and Conquer Algorithm
Divide and Conquer algorithm is a problem-solving strategy that involves breaking down a complex problem into smaller, more manageable parts, solving each part individually, and then combining the solutions to solve the original problem. It is a widely used algorithmic technique in computer science and mathematics. Example: In the Merge Sort algori
4 min read
Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
Given three positive integers N, A, and B. The task is to count the numbers of length N containing only digits A and B and whose sum of digits also contains the digits A and B only. Print the answer modulo 109 + 7.Examples: Input: N = 3, A = 1, B = 3 Output: 1 Possible numbers of length 3 are 113, 131, 111, 333, 311, 331 and so on... But only 111 i
15 min read
Count ways to generate pairs having Bitwise XOR and Bitwise AND equal to X and Y respectively
Given two integers X and Y, the task is to find the total number of ways to generate a pair of integers A and B such that Bitwise XOR and Bitwise AND between A and B is X and Y respectively Examples: Input: X = 2, Y = 5Output: 2Explanation:The two possible pairs are (5, 7) and (7, 5).Pair 1: (5, 7)Bitwise AND = 5 & 7 = 2Bitwise XOR = 5 ^ 7 = 5P
7 min read
Sum of Bitwise AND of sum of pairs and their Bitwise AND from a given array
Given an array arr[] consisting of N integers, the task is to find the sum of Bitwise AND of (arr[i] + arr[j]) and Bitwise AND of arr[i] and arr[j] for each pair of elements (arr[i], arr[j]) from the given array. Since the sum can be very large, print it modulo (109 + 7). Examples: Input: arr[] = {8, 9}Output: 0Explanation: The only pair from the a
9 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg