CS 415, Section 002 | Sonoma State University | Spring, 2022 |
Algorithm Analysis
|
||
Instructor: Henry M. Walker
Lecturer, Sonoma State University |
Instructions:
Consider the following as the 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.
Refer to the Diagram of the SSU Computer Science curriculum for the current SSU/CS curriculum. Arrows in the diagram represent prerequisites, and dotted lines of co-requisites should be ignored.
Consider the following directed graph:
Consider the following undirected graph:
Find the minimum cost spanning tree, showing the main steps in applying the algorithm.
Given an undirected graph, a minimum cost spanning trees need not be unique. Given an example of a graph with two different minimum cost spanning trees, where the graph has the fewest number of vertices and the fewest number of edges. In addition to displaying the graph and the two different minimum cost spanning trees, provide an explanation as to why this graph is the smallest possible with two different such trees.
Construct a Huffman tree from the following set of frequencies. (Always put the smaller subtree to the left. If there is a tie, put the leaf to the left.)
a | b | c | e | g | i | j | o | m | n | p | r | s | t | u | <space> |
2 | 1 | 4 | 4 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 3 | 2 | 5 |
Decode the front of the AP Computer Science t-shirt for 2002.
The Huffman algorithm generates a tree with a guaranteed minimum external path length. The optimal binary search tree algorithm generates a tree with a guaranteed minimum cost, where the cost minimizes the weighted internal and external path lengths.
If all of the internal node weights of a binary tree are 0, then the internal path length must be 0, so the total cost is the same as the external path length. Does this mean that the Huffman algorithm and the optimal binary search tree algorithm give the same result? Justify your answer.
created October-December, 2014 revised December-January 2021 |
![]() ![]() |
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |