Category Archives: Divide and Conquer

Allocate minimum number of pages

Given number of pages in n different books and m students. The books are arranged in ascending order of number of pages. Every student is assigned to read some consecutive books. The task is to assign books in such a way that the maximum number of pages assigned to a student is minimum. Input :… Read More »

Easy way to remember Strassen’s Matrix Equation

Strassen’s matrix is a Divide and Conquer method that helps us to multiply two matrices(of size n X n). You can refer to the link, for having the knowledge about Strassen’s Matrix first : Divide and Conquer | Set 5 (Strassen’s Matrix Multiplication) But this method needs to cram few equations, so I’ll tell you… Read More »

Find cubic root of a number

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 Root is 2.000000 We can use binary search. First we define error e. Let us say 0.0000001 in our case. The main steps of our algorithm for calculating the… Read More »

Longest Common Prefix | Set 3 (Divide and Conquer)

Given a set of strings, find the longest common prefix. 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 the arrays… Read More »