Todos os livros

Profissional

Apps Sobre Coach Entrar Começar a ler

Computer Science · Glossário

O que é Recurrence relation, recursion tree?

Também chamado de: recurrence relation · recursion tree

Definition 13.11 University Computer Science — Year 1 · Capítulo 13 — Asymptotic Analysis and Recurrences

A recurrence relation defines a cost function by its values on small sizes and an equation expressing T(n)T(n) in terms of values on smaller sizes. The recursion tree of such an equation has a node for each call, labelled with the cost spent in that call outside its recursive calls; its children are the calls it makes. T(n)T(n) is the sum of all the labels, which one often computes level by level.

The recursion tree of T(n) = 2T(n/2) + n: every level costs n, and there are _2 n levels above the leaves, hence T(n) = n _2 n + nT(1) for n a power of 2.
The recursion tree of T(n)=2T(n/2)+nT(n) = 2T(n/2) + n: every level costs nn, and there are log⁡2n\log_2 n levels above the leaves, hence T(n)=nlog⁡2n+nT(1)T(n) = n\log_2 n + nT(1) for nn a power of 2.
The three regimes of the master theorem, drawn as the cost of each level of the recursion tree (one bar per level, from the root down). The level costs form a geometric sequence of ratio a/bk: decreasing, the root’s term dominates; constant, the _b n levels add up; increasing, the leaves dominate.
The three regimes of the master theorem, drawn as the cost of each level of the recursion tree (one bar per level, from the root down). The level costs form a geometric sequence of ratio a/bka/b^k: decreasing, the root’s term dominates; constant, the log⁡bn\log_b n levels add up; increasing, the leaves dominate.
Ler no capítulo →