Turn in solutions to these problems. (Below they're marked
with this image: )
Important: Put the answer to each question on a separate sheet of paper (or one problem on front and another on the back). This is to make grading easier for us.
Collaboration Rules for This Assignment:
Here's an example of pruning. Sometimes the path found so far may divide the set of unvisited nodes into two sets that are "cut off" from each other. For example, in the graph below, if the exhaustive search algorithm starts off choosing the path A-C-E then we can tell by looking that this will not lead to a solution, i.e. there cannot be a Hamilton Cycle that contains A-C-E. See why? This path has divided the graph into two parts: no path can connect B with any node in {D, F} without re-visiting a node that's already been visited.
If we implement this pruning strategy, the change in the code for exhaustive search might look like this:
if (!visit[v]&& !cutInTwo(adj,visit) )
exh_search_recurs(adj,v)
Question (3 parts):
First, Describe clearly a strategy for the cutInTwo() function.
You can answer this by writing a few sentences
describing an approach that solves this problem.
Second, give an upper-bound on the time-complexity for one call
to cutInTwo().
Third, discuss in a few sentences whether or not you think it
would be cost effective to make this change
if you were using this exhaustive search strategy to find all Hamilton
cycles found in large, moderately dense
graphs.
Develop a greedy algorithm for either
one of these problems:
(a) Vertex cover problem -- see problem 7.8 on page 320 in the book
(b) Graph coloring problem, as follows:
A valid coloring of a graph is an assignment of a color (represented by
an int value: 1, 2, ...) to each vertex
such that no pair of adjacent vertices have the same color. An obvious
way to give a graph a valid coloring is
to assign each vertex an unique color, but often we want a valid
coloring that uses the smallest number of colors.
This is the optimization problem version of graph coloring, and this is
the one you need to develop a greedy algorithmn
for.
Thus the input is a graph G, and the output is an array or dictionary
color[] where color[i] is the color assigned to the ith
vertex. The answered stored in the color[] array should try to use the
smallest number of colors possible.
Note on both of these: Using the greedy approach will almost
certainly not produce an optimal solution.
Also to do: Give me an
input to your problem that causes your algorithm to not
produce an optimal solution. (Worth 10% of this problem.)
For the following problems, this the example graph to use:
G1) Carry out Kruskal's MST algorithm on the above graph. List edges in the final spanning tree in the order they were selected, and give the total weight of the tree.
G2) Carry out Prim's MST algorithm on the above graph. List the edges in the order they were selected. Also, when a candidate edge that's stored in the priority queue is replaced with a better candidate edge, list the replaced edge and what replaces it.
G3) Carry out Dijkstra's shortest path algorithm on the above graph. List the edges in the order they were selected. Also, when a candidate edge that's stored in the priority queue is replaced with a better candidate edge, list the replaced edge and what replaces it.
G4) In Prim's MST algorithm, give a list of what the priority queue operations are, what they do, when they occur.
G5) For each of the above priority queue operations, how often can they occur in the worst-case for some graph G?
G6) State the greedy selection rule (aka the selection function) for these algorithms:
G7) What in Prim's MST algorithm prevents the algorithm from choosing an infeasible solution?