Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas


Complexidade de Algorítmos Lista 9, Exercícios de Algoritmos e Programação

Apostilas de Complexidade de Algorítmos da Universidade Estadual de Campinas, Segundo Semestre de 2011, 9 Lista de Exercícios.

Tipologia: Exercícios

2013

Compartilhado em 03/12/2013

Salamaleque
Salamaleque 🇧🇷

4.5

(113)

201 documentos

1 / 1

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
MO417 Complexidade de Algoritmos
Segundo Semestre de 2011
Nona Lista de Exerc´
ıcios
Caminhos M´
ınimos
1. Give a simple example of a directed graph with negative-weight edges for which Dijkstra’s
algorithm produces incorrect answers.
2. We are given a directed graph G = (V, E) on which each edge (u, v) E has an associated value
r(u, v), which is a real number in the range 0 r(u, v) 1 that represents the reliability of a
communication channel from vertex u to vertex v. We interpret r(u, v) as the probability that
the channel from u to v will not fail, and we assume that these probabilities are independent.
Give an efficient algorithm to find the most reliable path between two given vertices.
3. Suppose we change the line:
“while Q6=Ø”
of Dijkstra’s algorithm to the following:
“while |Q|>1
This change causes the while loop to execute |V| 1times instead of |V|times. Is this proposed
algorithm correct?
4. Let G = (V, E) be a weighted, directed graph with weight function w:E {0,1,...,W}for
some nonnegative integer W. Modify Dijkstra’s algorithm to compute the shortest paths from a
given source vertex s in O(W V +E)time.
5. Modify your algorithm from previous exercise to run in O((V+E) lg W)time.
6. Modify the Bellman-Ford algorithm so that it sets d[v] to −∞ for all vertices v for which there
is a negative-weight cycle on some path from the source to v.
7. Given a weighted, directed graph G = (V, E) with no negative-weight cycles, let mbe the
maximum over all pairs of vertices u,vV of the minimum number of edges in a shortest path
from uto v. Here, the shortest path is by weight, not the number of edges. Suggest a simple
change to the Bellman-Ford algorithm that allows it to terminate in m+ 1 passes.
8. Give an efficient algorithm to count the total number of paths in a directed acyclic graph.
Analyze your algorithm.
1
docsity.com

Pré-visualização parcial do texto

Baixe Complexidade de Algorítmos Lista 9 e outras Exercícios em PDF para Algoritmos e Programação, somente na Docsity!

MO417 – Complexidade de Algoritmos

Segundo Semestre de 2011

Nona Lista de Exerc´ıcios

Caminhos M´ınimos

  1. Give a simple example of a directed graph with negative-weight edges for which Dijkstra’s algorithm produces incorrect answers.
  2. We are given a directed graph G = (V, E) on which each edge (u, v) ∈ E has an associated value r(u, v), which is a real number in the range 0 ≤ r(u, v) ≤ 1 that represents the reliability of a communication channel from vertex u to vertex v. We interpret r(u, v) as the probability that the channel from u to v will not fail, and we assume that these probabilities are independent. Give an efficient algorithm to find the most reliable path between two given vertices.
  3. Suppose we change the line: “while Q 6 = Ø” of Dijkstra’s algorithm to the following: “while |Q| > 1 ” This change causes the while loop to execute |V | − 1 times instead of |V | times. Is this proposed algorithm correct?
  4. Let G = (V, E) be a weighted, directed graph with weight function w : E → { 0 , 1 ,... , W } for some nonnegative integer W. Modify Dijkstra’s algorithm to compute the shortest paths from a given source vertex s in O(W V + E) time.
  5. Modify your algorithm from previous exercise to run in O((V + E) lg W ) time.
  6. Modify the Bellman-Ford algorithm so that it sets d[v] to −∞ for all vertices v for which there is a negative-weight cycle on some path from the source to v.
  7. Given a weighted, directed graph G = (V, E) with no negative-weight cycles, let m be the maximum over all pairs of vertices u, v ∈ V of the minimum number of edges in a shortest path from u to v. Here, the shortest path is by weight, not the number of edges. Suggest a simple change to the Bellman-Ford algorithm that allows it to terminate in m + 1 passes.
  8. Give an efficient algorithm to count the total number of paths in a directed acyclic graph. Analyze your algorithm.

docsity.com