0% found this document useful (0 votes)
15 views3 pages

Homework 5. Due: Monday, March, 7 2022 Before 8am EDT. Practice Problems (Don't Turn In) : Dijkstra's Algorithm

The document outlines Homework 5 due on March 7, 2022, which includes practice problems related to graph algorithms such as Dijkstra's algorithm and various problems from the DPV textbook. It provides instructions for graded problems, emphasizing the use of black-box algorithms without modification and requiring explanations of the algorithms' correctness and running time. Specific problems include designing an algorithm for a directed acyclic graph and determining feasible routes in a city-highway graph with fuel constraints.

Uploaded by

l
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Homework 5. Due: Monday, March, 7 2022 Before 8am EDT. Practice Problems (Don't Turn In) : Dijkstra's Algorithm

The document outlines Homework 5 due on March 7, 2022, which includes practice problems related to graph algorithms such as Dijkstra's algorithm and various problems from the DPV textbook. It provides instructions for graded problems, emphasizing the use of black-box algorithms without modification and requiring explanations of the algorithms' correctness and running time. Specific problems include designing an algorithm for a directed acyclic graph and determining feasible routes in a city-highway graph with fuel constraints.

Uploaded by

l
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: 1

Homework 5.
Due: Monday, March, 7 2022 before 8am EDT.

Practice problems (don’t turn in):

1. Dijkstra’s algorithm: This is not covered in the lectures because it’s the sort of thing many
of you have seen before, possibly multiple times. If you haven’t seen it, or need a refresher,
look at Chapter 4.4 of [DPV]. We will assume you know the answer to the following questions:
(a) What is the input and output for Dijkstra’s algorithm?
(b) What is the running time of Dijkstra’s algorithm using min-heap (aka priority queue)
data structure? (Don’t worry about the Fibonacci heap implementation or running time
using it.)
(c) What is the main idea for Dijkstra’s algorithm?
2. [DPV] Problem 3.3 (Topological ordering example)

3. [DPV] Problem 3.4 (SCC algorithm example)


4. [DPV] Problem 3.5 (Reverse of graph)
5. [DPV] Problem 3.8 (Pouring water), if your book has a part (c) you can skip it... or not... this
is just practice!

6. [DPV] Problem 3.15 Computopia.

1
Name: 2

Instructions.

For the graded problems, you are allowed to use the algorithms from class as black-boxes
without further explanation. These include
• DFS (outputs connected components, a path between two vertices, topological sort
on a DAG. You also have access to the pre and post arrays!), BFS and the Explore
subroutine.

• Dijkstra’s algorithm to find the shortest distance from a source vertex to all
other vertices and a path can be recovered backtracking over the pre labels.
• Bellman-Ford and Floyd-Warshall to compute the shortest path when weights are allowed
to be negative.

• SCCs which outputs the strongly connected components, and the metagraph of connected
components.
• Kruskal’s and Prim’s algorithms to find MST.
• Ford-Fulkerson and Edmonds-Karp to find max flow on networks.

When using a black-box, make sure you clearly describe which input you are passing
to it and how you use the output from or take advantage of the data structures created
by the algorithm. To receive full credit, your solution must:
• Include the description of your algorithm in words (no pseudocode!).

• Explain the correctness of your design.


• State and analyse the running time of your design (you can cite and use the running
time of black-boxes without further explanations).

Unless otherwise indicated, black-box graph algorithms should be used without modification.

Example: I take the input graph G, I first find the vertex with largest degree, call it v ∗ . I take the
complement of the graph G, call it G. Run Dijkstra’s algorithm on G with s = v ∗ and then I get
the array dist[v] of the shortest path lengths from s to every other vertex in the graph G. I square
each of these distances and return this new array.

We don’t want you to go into the details of these algorithms and tinker with it, just use it as a
black-box as showed with Dijkstra’s algorithm above. Make sure to explain your algorithm in words,
no pseudocode.

2
Name: 3

Problem 1 (A path that visits all vertices)


Design an algorithm that takes as input a directed acyclic graph and returns true if there is a directed
path that visits all vertices, and returns false otherwise.

Problem 2 [DPV] 4.13 (cities and highways)


You are given a set of cities, along with the pattern of highways between them, in the form of an
undirected graph G = (V, E). Each stretch of highway e ∈ E connects two of the cities, and you
know its length in miles, `e . You want to get from city s to city t. There’s one problem: your car
can only hold enough gas to cover L miles. There are gas stations in each city, but not between
cities. Therefore, you can only take a route if every one of its edges has length `e ≤ L.

(a) Given the limitation on your car’s fuel tank capacity, show how to determine in linear time
whether there is a feasible route from s to t.

(b) You are now planning to buy a new car, and you want to know the minimum fuel tank
capacity that is needed to travel from s to t. Give an O((|V | + |E|)log|V |) algorithm to determine
this. (Note: to solve part (b) you may modify known algorithms – if you do so, be sure to explain
your modifications in detail and how those modifications impact the known run time, if at all.)

You might also like