Category Archives: Divide and Conquer

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 »