13.04.2013 Views

Algoritmos e complexidade Notas de aula - Arquivo Escolar

Algoritmos e complexidade Notas de aula - Arquivo Escolar

Algoritmos e complexidade Notas de aula - Arquivo Escolar

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7. Árvores <strong>de</strong> busca, backtracking e branch-and-bound<br />

4 C1 := minVertexCover(G − u) ∪ {u}<br />

5 C2 := minVertexCover(G − v) ∪ {v}<br />

6 return a menor cobertura C1 ou C2<br />

Solução ótima?<br />

1<br />

3<br />

20 21<br />

18<br />

19<br />

17<br />

2<br />

23<br />

22<br />

24<br />

4<br />

16<br />

A <strong>complexida<strong>de</strong></strong> da solução acima satisfaz Tn = 2Tn−1 + Θ(n) = Θ(2 n ).<br />

Observação 7.1<br />

• Caso o grau máximo ∆ <strong>de</strong> G é 2, o problema po<strong>de</strong> ser resolvido em<br />

tempo O(n), porque G é uma coleção <strong>de</strong> caminhos simples e ciclos.<br />

10<br />

25<br />

15<br />

• Caso contrário, temos ao menos um vértice v <strong>de</strong> grau δv ≥ 3. Ou esse<br />

vértice faz parte da cobertura mínima, ou todos seus vizinhos N(v) (ver<br />

figura 7.1).<br />

♦<br />

1 mvc ′ (G) :=<br />

2 i f ∆(G) ≤ 2 then<br />

3 <strong>de</strong>termina a cobertura mínima C em tempo O(n)<br />

4 return C<br />

5 end i f<br />

6 s e l e c i o n a um v é r t i c e v com grau δv ≥ 3<br />

160<br />

5<br />

13<br />

14<br />

6<br />

9<br />

12<br />

8<br />

7<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!