Salta al contenuto
Note per Studenti Parametric Induction Report

Parametric Induction

In questa pagina 5

Unfolding (Divide and Conquer - Paradigm and Call TreeA divide-and-conquer algorithm comes from a substructure property (threshold n0, Divide and Conquer functions) with strictly smaller subinstances; the call tree describes the execution, and D&C has no memory (equal subinstances are recomputed). Complete example: MAX of an array, with correctness by induction, the recurrence, and the exact count n-1 via the theorem on full binary trees.Divide and Conquer - Paradigm and Call Tree →) gives a closed form for n=bkn=b^k. For arbitrary nn, with floors and ceilings, the exact form may be very hard to find. One then states a guess on the growth and tries to prove it rigorously: parametric induction. The closed form for n=bkn=b^k suggests the order of growth (not the constants); for a wide class there is also the Master TheoremThe Master Theorem for T(n) = aT(n/b) + w(n) compares w(n) with the threshold n^(log_b a). Case 1 (w polynomially smaller): Theta(n^(log_b a)); case 2 (same order): Theta(n^(log_b a) log n); case 3 (polynomially larger and regular): Theta(w(n)). Full proof from the levels of the tree, extended version with floors and ceilings, a table of applications, and the misuse when no case applies (w = n log n).Master Theorem →.

Method

Simulate an induction proof of a closed-form bound whose constants are parameters determined at the end, accumulating constraints that make every step valid. Typical guess: ∃c∈R+, d∈R:∀n>0T(n)≤c n+d(or ≥),\exists c\in\mathbb R^+,\ d\in\mathbb R:\quad\forall n>0\quad T(n)\le c\,n+d\quad(\text{or }\ge), i.e. O(n)O(n) (or Ω(n)\Omega(n)); both together give Θ(n)\Theta(n). cc and dd are the same for all nn.

  1. Base [B]. Impose the guess on base values: each base nn gives a constraint.
  2. Hypothesis [HP]. Assume the guess for all arguments smaller than nn.
  3. Step [HP ⇒\Rightarrow TH]. Apply the definition of T(n)T(n), use [HP], simplify with equalities or always-valid bounds, and write the conditional inequality ≤?\overset{?}{\le} whose truth (for some c,dc,d) yields the thesis. The symbol ≤?\overset?\le marks a condition on the parameters, not an always-true bound.
  4. Intersection. If the set of constraints is nonempty, any admissible pair turns the proof into a normal induction. For an upper bound take the smallest cc (best constant of the dominant term); for a lower bound the largest cc.

The method is not infallible. If the guess is false the constraint set is certainly empty, but it may be empty for a true guess too, when the tool is too weak. Failure does not disprove the guess. Afterwards confirm with a standard induction to catch calculation errors.

Example 1: upper bound for MAX

T(1)=0T(1)=0, T(n)=T(⌊n/2⌋)+T(⌈n/2⌉)+1T(n)=T(\lfloor n/2\rfloor)+T(\lceil n/2\rceil)+1. Guess: T(n)≤cn+dT(n)\le cn+d, c>0c>0.

  • [B] n=1n=1: 0≤?c+d0\overset?\le c+d. Constraint: c+d≥0c+d\ge0.
  • [HP ⇒\Rightarrow TH] For n>1n>1 both arguments are <n<n and ≥1\ge1: T(n)≤(c⌊n/2⌋+d)+(c⌈n/2⌉+d)+1=c n+(2d+1),T(n)\le\bigl(c\lfloor n/2\rfloor+d\bigr)+\bigl(c\lceil n/2\rceil+d\bigr)+1=c\,n+(2d+1), since ⌊n/2⌋+⌈n/2⌉=n\lfloor n/2\rfloor+\lceil n/2\rceil=n. We need cn+2d+1≤?cn+d  ⟺  d≤−1cn+2d+1\overset?\le cn+d\iff d\le-1.

Constraints: c+d≥0c+d\ge0, d≤−1d\le-1, hence c≥1c\ge1. The minimum is c=1c=1 and then d=−1d=-1 is forced: T(n)≤n−1.T(n)\le n-1.

Example 2: lower bound for MAX

Guess T(n)≥c′n+d′T(n)\ge c'n+d'. [B] c′+d′≤0c'+d'\le0. [Step] T(n)≥c′n+2d′+1T(n)\ge c'n+2d'+1, enough that 2d′+1≥d′2d'+1\ge d', i.e. d′≥−1d'\ge-1. For a lower bound take c′c' maximum: c′≤−d′≤1c'\le-d'\le1, so c′=1c'=1, d′=−1d'=-1. Hence T(n)≥n−1T(n)\ge n-1 and with Example 1, T(n)=n−1T(n)=n-1 for all nn. This is a lucky case: usually the bounds do not coincide in the constants.

Example 3: when the simplest guess fails

Guess T(n)≤c nT(n)\le c\,n for MAX (true with c=1c=1). [B] c≥0c\ge0. [Step] T(n)≤cn+1T(n)\le cn+1, and cn+1≤?cncn+1\overset?\le cn is satisfied by no cc. The intersection is empty although the guess is true: with a single parameter the tool is too weak, the +1+1 is not absorbed. Adding the lower-order term dd (d≤−1d\le-1) fixes it. Practical rule: try a one-parameter guess first; add parameters only after a failure.

Example 4: a guess with nlog⁡nn\log n

T(1)=1T(1)=1, T(n)=2T(⌊n/2⌋)+nT(n)=2T(\lfloor n/2\rfloor)+n. The Master Theorem suggests Θ(nlog⁡n)\Theta(n\log n). The guess T≤cnlog⁡2nT\le cn\log_2n fails at the base: for n=1n=1 it gives 0<10<1 whatever cc. Add a linear term: T(n)≤c nlog⁡2n+d nT(n)\le c\,n\log_2n+d\,n.

  • [B] 1≤d1\le d: constraint d≥1d\ge1.
  • [Step] For n>1n>1, 1≤⌊n/2⌋<n1\le\lfloor n/2\rfloor<n, and x↦xlog⁡2xx\mapsto x\log_2x is non-decreasing for x≥1x\ge1 with ⌊n/2⌋≤n/2\lfloor n/2\rfloor\le n/2, 2⌊n/2⌋≤n2\lfloor n/2\rfloor\le n, d>0d>0: T(n)≤2[c⌊n2⌋log⁡2⌊n2⌋+d⌊n2⌋]+n≤c n(log⁡2n−1)+dn+n=cnlog⁡2n+dn+(1−c)n≤?cnlog⁡2n+dn  ⟺  c≥1.T(n)\le2\Bigl[c\lfloor\tfrac n2\rfloor\log_2\lfloor\tfrac n2\rfloor+d\lfloor\tfrac n2\rfloor\Bigr]+n\le c\,n(\log_2n-1)+dn+n=cn\log_2n+dn+(1-c)n\overset?\le cn\log_2n+dn\iff c\ge1.

Constraints c≥1c\ge1, d≥1d\ge1; with minimum cc: T(n)≤nlog⁡2n+nT(n)\le n\log_2n+n, with equality for n=2kn=2^k (unfolding gives T(2k)=2kk+2kT(2^k)=2^kk+2^k).

Versione ripasso