0% found this document useful (0 votes)
34 views2 pages

Algorithm 2017 Spring Homework 4: 範圍:Chapter 22~ Chapter 24

This document summarizes the homework assignments for an algorithms course covering chapters 22-24. It includes 5 questions: 1) Using depth-first search to find discovery and finish times on a given graph; 2) Determining if a feasible solution exists for a system of difference constraints; 3) Explaining Dijkstra's algorithm on a sample graph and conditions for when it does not work; 4) Running the DAG shortest path algorithm on a directed acyclic graph; 5) Providing an O(V) time algorithm to determine if an undirected graph contains a cycle.

Uploaded by

woogie boogie
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)
34 views2 pages

Algorithm 2017 Spring Homework 4: 範圍:Chapter 22~ Chapter 24

This document summarizes the homework assignments for an algorithms course covering chapters 22-24. It includes 5 questions: 1) Using depth-first search to find discovery and finish times on a given graph; 2) Determining if a feasible solution exists for a system of difference constraints; 3) Explaining Dijkstra's algorithm on a sample graph and conditions for when it does not work; 4) Running the DAG shortest path algorithm on a directed acyclic graph; 5) Providing an O(V) time algorithm to determine if an undirected graph contains a cycle.

Uploaded by

woogie boogie
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/ 2

Algorithm 2017 Spring

Homework 4
範圍:Chapter 22~ Chapter 24

1. (20pts) Given the following undirected graph.


Please use the Depth-First-Search algorithm to show the
timestamp (discovery time and finish time) starting from vertex s
of each vertex on it.

2. (20pts) Find a feasible solution or determine that no feasible


solution exists for the following system of difference constraints
x1 − x2 ≤ 4, x1 − x5 ≤ 5, x2 − x4 ≤ −6, x3 − x2 ≤ 1,
x4 − x1 ≤ 3, x4 − x3 ≤ 5, x4 − x5 ≤ 10, x5 − x3 ≤ −7,
x5 − x4 ≤ −8

3. Consider the single-source shortest-paths problem. The execution


process of Dijkstra’s algorithm can be decomposed into V−1
stages. At each stage, the algorithm finds a shortest path from the
source to a vertex.
(a) (10pts) Describe such a process clearly on the following
di-graph with vertex a as the source.
(b) (10pts) Under what condition Dijkstra’s algorithm will not
work? Given an example to explain your answer.
4. (20pts) Run DAG-SHORTEST-PATHS step by step on the
directed graph of the figure, using vertex s as the source.

5. (20pts) Give an algorithm (or pseudocode) that determines


whether or not a given undirected graph G = (V ,E) contains a
cycle. Your algorithm should run in O(V) time, independent of |E|.
Please explain your answer.

You might also like