# Divide and Conquer Paradigm (What it is, Its Applications, Pros and Cons)

In this article, we are going to learn the **concept of divide and conquer programming paradigm and its algorithms along with its applications**.

Submitted by Deepak Dutt Mishra, on June 30, 2018

In the branch of Computer Science and Engineering, Information Technology and all the associated branches among these fields the term **"Divide and Conquer"** is an algorithm design paradigm based on the principle of recursion ( multi-branched). In this algorithmic approach, the algorithm designed works recursively by breaking down the problem in hand, into two or more sub-problems or parts based on the complexity of the problem. This sub-problems or parts are also called atomic or fractions. This atomics or fractions are recursively broken down into more and more atomic or fractions until they are broken down into a form that can be solved. After solving these fractions or atomics they are then again traversed back recursively but this time instead of breaking down the problem, the problems are merged back with their recursively broken counterparts then the required solution for that particular problem is generated.

**Divide and Conquer Approach** is divided into three processes and these three processes form the basis of divide and conquer paradigm for problem-solving:

### 1) Divide

The first and foremost process for solving any problem using Divide and Conquer paradigm. As suggested by the name it’s function is just to divide the problem into sub-problem which in turn if are more complex then are again divided into more sub-parts. Basically , if we consider for example binary search ( an example of Divide and Conquer approach ) the given list is broken ( under some specified consider defined by its algorithm and user input ) into single elements among which then the element to search is compared and the user gets a prompt whether the element is in the list.

### 2) Conquer

This process is referred to as ‘ Conquer ’ because this process is what which performs the basic operation of a defined algorithm like sort in cases of various sorts, finds the element to be searched in case of binary search, multiplying of the numbers in Karatsuba Algorithm and etc. But almost among algorithms at least the most basic ones that we study mostly are considered to be solved in this part since the divide part breaks them into single elements which can be simply solved.

### 3) Merge

This is the last process of the **'Divide'** and **'Conquer'** approach whose function is to recursively rebuild the original problem but what we get now is the solution to that problem. In merge procedure, the solved elements of the ‘ Conquer ‘ are recursively merged together like the way they divided in the first step i.e. ‘ Divide’.

The steps **'Conquer'** and **'Merge'** work so close that sometimes they are treated as a single step. The Divide and Conquer can be implemented in two ways:

**Naturally**i.e. by using recursion**Explicitly**i.e. by using data structures like stack and queues etc

One of the major **characteristics of Divide and Conquer** is that the time complexity of its algorithms can be easily calculated by solving recurrence relations and its correctness can be evaluated via Mathematical Induction.

## Applications of Divide and Conquer Strategy

- Binary Search (C program for binary search)
- Merge Sort (Merge sort | C++ Example)
- Quick Sort (Quick sort | C++ Example)
- Closest Pair of Points
- Strassen’s Multiplication
- Karatsuba Algorithm
- Cooley-Tukey Algorithm

### Pros of Divide and Conquer Strategy

- Solves difficult problems with ease.
- Algorithms designed with Divide and Conquer strategies are efficient when compared to its counterpart Brute-Force approach for e.g. if we compare time complexity of simple matrix multiplication i.e. O(n3) and that of Strassen's matrix multiplication i.e. O(n2.81).
- Algorithms designed under Divide and Conquer strategy does not require any modification as they inhibit parallelism and can easily be processed by parallel processing systems.
- It makes efficient use of memory cache this happens so because that problems when divided gets so small that they can be easily solved in the cache itself.
- If we use floating numbers then the results may improve since round off control is very efficient in such algorithms.

### Cons of Divide and Conquer Strategy

**Divide and Conquer**strategy uses recursion that makes it a little slower and if a little error occurs in the code the program may enter into an infinite loop.- Usage of explicit stacks may make use of extra space.
- If performing a recursion for no. times greater than the stack in the CPU than the system may crash.
- Choosing base cases is also a limitation as picking small cases may work if the cases are taken much higher than the capacity of the system than problems may occur.
- Sometimes a case where the problem when broken down results in same subproblems which may needlessly increase the solving time and extra space may be consumed.

Related Tutorials

- Introduction to Algorithms
- Introduction to Greedy Strategy in Algorithms
- Stability in sorting
- External Merge Sorting Algorithm
- Radix Sort and its Algorithm
- Bucket Sort Algorithm
- Bubble sort Algorithm, Flow Chart and C++ Code
- Insertion sort Algorithm, flowchart and C, C++ Code
- Merge Sort | One of the best sorting algorithms used for large inputs
- Binary Search in C, C++
- Randomized Binary Search
- Meta Binary Search | One-sided Binary Search
- Difference between Linear Search and Binary Search
- Binary Search in String
- Variants of Binary Search
- Sieve of Eratosthenes to find prime numbers
- Optimal Merge Pattern (Algorithm and Example)
- Given an array of n numbers, Check whether there is any duplicate or not
- Finding the missing number
- Find the number occurring an odd number of times
- Find the pair whose sum is closest to zero in minimum time complexity
- Find three elements in an array such that their sum is equal to given element K
- Bitonic Search Algorithm
- Check whether a number is Fibonacci or not
- Segregate even and odd numbers in minimum time complexity
- Find trailing zeros in factorial of a number
- Find Nearest Greatest Neighbours of each element in an array
- Interpolation search algorithm
- Floor and ceil of an element in an array using C++
- Two Elements whose sum is closest to zero
- Find a pair with a given difference
- Count number of occurrences (or frequency) in a sorted array
- Find a Fixed Point (Value equal to index) in a given array
- Find the maximum element in an array which is first increasing and then decreasing
- Dynamic Programming (Components, Applications and Elements)
- Algorithm for fractional knapsack problem
- Algorithm and procedure to solve a longest common subsequence problem
- Find the Nth Fibonacci number | C++
- Longest Common Subsequence using Dynamic programming (DP)
- Longest Increasing Subsequence using Dynamic programming (DP)
- Find the maximum sub-array sum using KADANE'S ALGORITHM
- Non-intersecting chords using Dynamic Programming (DP)
- Edit Distance using Dynamic Programming (DP)
- Finding Ugly Number using Dynamic Programming (DP)

- Backtracking (Types and Algorithms)
- 4 Queen's problem and solution using backtracking algorithm
- N Queen's problem and solution using backtracking algorithm
- Find the GCD (Greatest Common Divisor) of two numbers using EUCLID'S ALGORITHM
- Compute the value of A raise to the power B using Fast Exponentiation
- Implement First Come First Served (FCFS) CPU Scheduling Algorithm using C program
- Implementations of FCFS scheduling algorithm using C++
- Implementation of Shortest Job First (SJF) Non-Preemptive CPU scheduling algorithm using C++
- Implementation of Shortest Job First (SJF) Preemptive CPU scheduling algorithm using C++
- Implementation of Priority scheduling (Pre-emptive) algorithm using C++
- Implementation of Priority scheduling (Non Pre-emptive) algorithm using C++
- Implementation of Round Robin CPU Scheduling algorithm using C++
- Analysis of LRU page replacement algorithm and Belady's anomaly
- Branch and Bound
- Find the roots of a complex polynomial equation using Regula Falsi Method in C
- Strassen's Matrix Multiplication in algorithms
- Huffman Coding (Algorithm, Example and Time complexity)
- Tournament Tree and their properties
- Deterministic and Non Deterministic Algorithms
- Lower Bound Theory
- Non Recursive Tree Traversal Algorithm
- Line Drawing Algorithm
- P and NP problems and solutions | Algorithms
- 2 – 3 Trees Algorithm
- Midpoint Circle Algorithm
- Reliability design problem
- Removing consecutive duplicates from a string
- Fast Exponentiation using Bitmasking
- Egg dropping problem using Dynamic Programming (DP)
- Wild card matching problem using Dynamic programming (DP)
- Compute sum of digits in all numbers from 1 to N for a given N
- Minimum jumps required using Dynamic programming (DP)
- Graph coloring problem's solution using backtracking algorithm
- Breadth First Search (BFS) and Depth First Search (DFS) Algorithms
- Travelling Salesman Problem
- Kruskal's (P) and Prim's (K) Algorithms
- Multistage graph problem with forward approach and backward approach algorithms
- Floyd Warshall algorithm with its Pseudo Code

What's New (MCQs)

- C Language MCQs
- Python MCQs
- Perl MCQs
- MongoDB MCQs
- Java MCQs
- C# MCQs
- Scala MCQs
- Blockchain MCQs
- AutoCAD MCQs
- ASP.Net MCQs
- PHP MCQs
- JavaScript MCQs
- jQuery MCQs
- ReactJS MCQs
- AngularJS MCQs
- JSON MCQs
- Ajax MCQs
- SASS MCQs
- HTML MCQs
- Advanced CSS MCQs
- CSS MCQs
- XML MCQs
- OOPs MCQs
- PL/SQL MCQs
- SQL MCQs
- MySQL MCQs
- Oracle MCQs
- SQLite MCQs
- CouchDB MCQs
- MS Word MCQs
- MS Excel MCQs
- MS PowerPoint MCQs
- Google Sheets MCQs
- Software Engineering MCQs
- Operating System MCQs
- Data Analytics and Visualization MCQs
- MIS MCQs
- Linux MCQs
- WordPress MCQs
- Blogging MCQs

- Energy & Environment Engineering MCQs
- Project Management MCQs
- Marketing MCQs
- Generally Accepted Accounting Principles MCQs
- Bills of Exchange MCQs
- Business Environment MCQs
- Sustainable Development MCQs
- Marginal Costing and Absorption Costing MCQs
- Globalisation MCQs
- Indian Economy MCQs
- Retained Earnings MCQs
- Depreciation MCQs
- Partnership MCQs
- Sole Proprietorship MCQs
- Goods and Services Tax (GST) MCQs
- Cooperative Society MCQs
- Capital Market MCQs
- Business Studies MCQs
- Basic Accounting MCQs
- MIS Executive Interview Questions
- Go Language Interview Questions

Top Interview Coding Problems/Challenges!

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions!