CS 415, Section 002 | Sonoma State University | Spring, 2022 |
Algorithm Analysis
|
||
Instructor: Henry M. Walker
Lecturer, Sonoma State University |
Consider the following adjacency matrix S for a weighted, directed graph. (Note: 0 means there is no edge.)
A | B | C | D | E | F | G | |
---|---|---|---|---|---|---|---|
A | 0 | 10 | 6 | 4 | 0 | 7 | 0 |
B | 10 | 0 | 9 | 0 | 11 | 0 | 18 |
C | 6 | 9 | 0 | 1 | 1 | 0 | 0 |
D | 4 | 0 | 1 | 0 | 1 | 2 | 0 |
E | 0 | 11 | 1 | 1 | 0 | 0 | 14 |
F | 7 | 0 | 0 | 2 | 0 | 0 | 15 |
G | 0 | 18 | 0 | 0 | 14 | 15 | 0 |
Draw a picture of the graph represented by this adjacency matrix S without the weights.
Is this graph directed or undirected? Explain.
List the vertices in depth-first order beginning with vertex A. When you have a choice among vertices, pick them in alphabetical order.
List the vertices in breadth-first order beginning with vertex A. Again, when you have a choice among vertices, pick them in alphabetical order.
Problems 5 and 6 are based on the following graph. (Note that 0 means there is no edge.)
Write the adjacency matrix for this graph, based upon the alphabetical ordering of the vertices given.
Draw the adjacency list representation for this graph.
The next four problems are based on the following adjacency matrix.
A | B | C | D | E | F | G | |
A | 0 | 10 | 6 | 4 | 0 | 7 | 0 |
B | 0 | 0 | 9 | 0 | 11 | 0 | 18 |
C | 6 | 9 | 0 | 1 | 1 | 0 | 0 |
D | 4 | 0 | 1 | 0 | 1 | 2 | 0 |
E | 0 | 0 | 1 | 1 | 0 | 0 | 14 |
F | 7 | 0 | 0 | 2 | 0 | 0 | 15 |
G | 0 | 18 | 0 | 0 | 0 | 0 | 0 |
Draw a picture of the graph represented by this adjacency matrix S without the weights.
Is the graph directed or undirected? Explain.
List the vertices in depth-first order beginning with Vertex A. When there is a choice, process the vertices and edges from left to right.
List the vertices in breadth-first order beginning with Vertex A. Again, when there is a choice, process the vertices and edges from left to right.
Suppose a connected graph has v vertices and e edges. What is the complexity of a breadth-first search?
Assume the queue is implemented with an array, and the graph by an adjacency matrix.
Assume the queue is implemented with a linked list, and the graph with adjacency lists.
A claim is made that a complete directed graph of n vertices has n(n-1) edges, while a complete undirected graph of n vertices has n(n01)/2 edges. Is this claim true? If so outline a proof. If not, give a counter example.
A claim is made that a binary tree is a directed, acyclic graph in which one vertex has in-degree of 0, all other vertices have in-degree 1, and all vertices have out-degree1 or 2. Is the converse true? That is, suppose G is a directed, acyclic graph with the above constrains on the in-degree and out-degree of its vertices. Must such a digraph be a binary tree? Justify your answer by given a proof tha the result must be true or by giving a counter example to show that it is false.
created December 1, 2018 revised December 2, 2018 revised December 27-30, 2021 revised February 4, 2022 |
|
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |