5 Problems - Algorithms – Homework | CMSC 351, Assignments of Algorithms and Programming

Material Type: Assignment; Professor: Kruskal; Class: Algorithms; Subject: Computer Science; University: University of Maryland; Term: Summer I 2008;

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-b31
koofers-user-b31 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Summer 2008 CMSC 351: Homework 9 Clyde Kruskal
Due at the start of class Friday, July 11, 2008.
Problem 1. Let G= (V, E) be a directed graph.
(a) Assuming that Gis represented by an adjacency matrix A[1..n,1..n], give a
Θ(n2)-time algorithm to compute the adjacency list representation of G. (Rep-
resent the addition of an element vto a list lusing pseudocode by ll {v}.)
(b) Assuming that Gis represented by an adjacency list Adj[1..n], give a Θ(n2)-time
algorithm to compute the adjacency matrix of G.
Problem 2. Do Exercise B.5-5 on page 1091 of CLRS.
Problem 3. Do Exercise 24.3-1 on page 600 of CLRS.
Problem 4. Give a simple example of a directed graph with negative weight edges, but no
negative weight cycles, for which Dijkstra’s algorithm produces incorrect answers.
Problem 5.
(a) What is the (optimization version of the) Longest Acyclic Path Problem?
(b) What is the decision version of the Longest Acyclic Path Problem?
(c) Show that the decision version of the Longest Acyclic Path Problem is in NP.

Partial preview of the text

Download 5 Problems - Algorithms – Homework | CMSC 351 and more Assignments Algorithms and Programming in PDF only on Docsity!

Summer 2008 CMSC 351: Homework 9 Clyde Kruskal

Due at the start of class Friday, July 11, 2008.

Problem 1. Let G = (V, E) be a directed graph.

(a) Assuming that G is represented by an adjacency matrix A[1..n, 1 ..n], give a Θ(n^2 )-time algorithm to compute the adjacency list representation of G. (Rep- resent the addition of an element v to a list l using pseudocode by l ← l ∪ {v}.) (b) Assuming that G is represented by an adjacency list Adj[1..n], give a Θ(n^2 )-time algorithm to compute the adjacency matrix of G.

Problem 2. Do Exercise B.5-5 on page 1091 of CLRS.

Problem 3. Do Exercise 24.3-1 on page 600 of CLRS.

Problem 4. Give a simple example of a directed graph with negative weight edges, but no negative weight cycles, for which Dijkstra’s algorithm produces incorrect answers.

Problem 5.

(a) What is the (optimization version of the) Longest Acyclic Path Problem? (b) What is the decision version of the Longest Acyclic Path Problem? (c) Show that the decision version of the Longest Acyclic Path Problem is in NP.