Questions tagged [divide-and-conquer]

Divide-and-conquer is an algorithmic technique in which a problem is divided into smaller subproblems, whose solutions are combined to a solution of the original problem. Classical examples include mergesort, quicksort, and FFT.

Divide-and-conquer is an algorithm technique in which a problem is divided into smaller subproblems, which are solved recursively, and their solutions are then combined into a solution of the original problem. The running time of such algorithms can often be computed using the Master theorem or its generalization, the Akra–Bazzi theorem.

As an example, mergesort and quicksort each partition their input into two subarrays ("divide"), which are then sorted recursively and put together ("conquer"). In the case of mergesort, divide is trivial and conquer requires work. The opposite is true for quicksort. The running times of both algorithms satisfies the recurrence $T(n) = 2T(n/2) + \Theta(n)$, whose solution is $\Theta(n\log n)$.

151 questions
32
votes
2 answers

Show how to do FFT by hand

Say you have two polynomials: $3 + x$ and $2x^2 + 2$. I'm trying to understand how FFT helps us multiply these two polynomials. However, I can't find any worked out examples. Can someone show me how FFT algorithm would multiply these two…
lars
  • 493
  • 1
  • 5
  • 8
22
votes
2 answers

Theoretical foundations of Divide and Conquer

When it comes to the design of algorithms, one often employs the following techniques: Dynamic Programming The Greedy-Strategy Divide-and-Conquer While for the first two methods, there are well-known theoretical foundations, namely the Bellman…
Cornelius Brand
  • 1,291
  • 9
  • 20
8
votes
5 answers

Divide and Conquer to identify a knight from n people

So I am doing an exercise in which there are $n$ people who are either knight or rogue, more than $\frac{n}{2}$ are knights. You are a princess and would like to marry a knight and do not want to accidentally marry a rogue. You can select any pair…
AlgoManiac
  • 83
  • 1
  • 4
8
votes
3 answers

Strassen algorithm for matrix multiplication complexity analysis

I see everywhere that the recursive equation for the complexity of Strassen alg is: $$T(n) = 7T(\tfrac{n}{2})+O(n^2).$$ This is not so clear to me. The parameter $n$ is supposed to be the size of the input, but it seems that here it is one dimension…
5
votes
0 answers

Obtaining max set interval intersection using Divide and Conquer

Given an array with $n>2$ elements of integer sets intervals, where each set is represented as a tuple of the form $(inf, sup)$ (with $inf $ ínfimum and $sup $ maximum of the set), we want to obtain the two intervals such that the number of…
5
votes
1 answer

Counting Total Number of Non-Equivalent Configurations in a 2-D Grid

This is a challenging question I've been trying (unsuccessfully) to solve via programming, math or both. Suppose you're given a 2D grid, whose width and height, $w$ and $h$, can each range from $1$ thru $12$ inclusive. Each cell in this grid can be…
5
votes
1 answer

Discrete fourier transform of a polynomial whose degree is not a power of 2

I need to evaluate a polynomial of degree n at the n cube roots of unity. Simple evaluation would take $O(n^2)$ time. I know that polynomial evaluation can be done in $O(n\log n)$ time using FFT. But the problem that I am facing is this. FFT only…
ashwin1907
  • 51
  • 1
4
votes
3 answers

Categorization of Binary search as Divide and Conquer

Why do we call binary search as 'Divide' and 'Conquer' strategy? It does not combine the results unlike other Divide and Conquer strategies.
4
votes
2 answers

$O(n \log n)$ simple polygon triangulation via divide and conquer

I am looking for the simplest possible $O(n \log n)$ algorithm for triangulating a simple polygon. It seems like there should be a simple divide and conquer variant that would fit the bill, ideally one avoiding auxiliary data structures such as…
3
votes
2 answers

Example divide and conquer algorithm with recurrence T(n) = T(n/2) + O(n)

I'm working on some lecture notes and wondered if there was a good example algorithm for the recurrence equation $$T(n) = T(n/2) + n$$ I know that I can do selection in this running time, but that is a probabilistic algorithm, and I was hoping not…
3
votes
1 answer

Find the asymptotic bound $\Theta$ of $t(n)=t(\frac{n}{5})+t(\frac{n}{17})+n$

Find the asymptotic bound in terms of $\Theta$ (Theta) using the master theorem for the following recursive equation. Assume that $t(n)= \Theta (1)$ for suffucuently small $n$. $$t(n)=t(\frac{n}{5})+t(\frac{n}{17})+n$$ I am a bit confused on…
3
votes
1 answer

Karatsuba Multiplication with n/3 division of large number

I was studying Karatsuba multiplication where the complexity is reduced as compared to classical algorithm by splitting each number into two parts. Now I'm trying to understand how the multiplication will take place when a number is divided into…
3
votes
1 answer

Algorithm in O(logn)

I have a project where I should write the following algorithm : Let an integer function $f\colon\{1,2,3,\ldots,n\} \to \mathbb{Z}$ be monotone and suppose that $f(1) > 0$ and $f(n) < 0$. We would like to find the smallest integer $i$ with $f(i) <…
3
votes
1 answer

Can Strassen's multiplication algorithm be improved if we divide matrices to 3x3 or axa in general?

Strassen's algorithm uses the divide and conquer approach to divide the matrix multiplication of two nxn matrices to multiplication of 7 2x2 matrices to get an overall complexity O(n^c) where c=log_2(7). I also read a paper which proved that it was…
3
votes
1 answer

Number of "hamiltonian tours" from upper left to lower left corner of a grid graph?

I got the following as an interview question: Count the number of tours from the upper left corner to the lower left corner in a grid world where you can move in any manhattan direction. This is the number of Hamiltonian paths from upper left to…
1
2 3
10 11