Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
3. Combine the solutions to the subproblems into the solution for the
original problem.
5. The algorithm then combines the solved base cases into solutions and
groups them by their subproblem units. Let’s now call them sub so-
lutions. Since the original subproblems were children of a large sub-
problem, the solutions will belong to parent groups. The assemblage
continues until 2 solution units are obtained. The last 2 solution units
are combined to form a single solution to the original problem.
1
1. Divide the problems until you have individual elements
1.2 Recurrences
A recurrence is an equation or inequality that describes a function in terms
of its value on smaller inputs.
Recurrences often take a problem with input n and divide it into 2 units:
2
1.4 Notes on Recurrences
Sometimes, a problem may have size, n such that n = 2m+1, that is n is
odd. Dividing this subproblem into 2 groups leaves on group with size odd.
So taking this into perspective, we actually need floors and Ceilings in
solving recurrences.
{ So a true recurrence equation is like below:
Θ(1) if n = 1
T(n) =
T (⌈n/2⌉) + T (⌊n/2⌋) + Θ(n) if n > 1