$23.99
1) Consider the weighted graph:
a) Demonstrate Prim's algorithm starting from vertex A. Write the edges in the order they were added to the minimum spanning tree.
1.
2.
3.
4.
5.
6.
7.
b) Demonstrate Dijkstra's algorithm on the graph, using vertex as the source. Write the vertices in the order which they are marked and compute all distances at each step.
1.
2.
3.
4.
5.
6.
7.
8.
2) A Hamiltonian path in a graph G = (V, E) is a simple path that includes every vertex in . Design an algorithm to determine if a directed acyclic graph (DAG) has a Hamiltonian path. Your algorithm should run in O(V+E). Provide a written description of your algorithm including why it works, pseudocode and an explanation of the running time.
Pseudo-code:
3) Below is a list of courses and prerequisites for a factious CS degree.
Draw a directed acyclic graph (DAG) that represents the precedence among the courses.
Note: CS 435 should have been CS 425
b) Give a topological sort of the graph.
c) Find an order in which all the classes can be taken. You are allowed to take multiple courses at one time as long as there is no prerequisite conflict.
d) Determine the length of the longest path in the DAG. How did you find it? What does this represent?
4) Suppose you have an undirected graph G=(V,E) and you want to determine if you can assign two colors (blue and red) to the vertices such that adjacent vertices are different colors. This is the graph Two-Color problem. If the assignment of two colors is possible, then a 2-coloring is a function C: V - {blue, red} such that C(u) C(v) for every edge (u,v) E. Note: a graph can have more than one 2-coloring.
a) Give a verbal description of the algorithm and provide detailed pseudocode.
b) Analyze the running time.
5) A region contains a number of towns connected by roads. Each road is labeled by the average number of minutes required for a fire engine to travel to it. Each intersection is labeled with a circle. Suppose that you work for a city that has decided to place a fire station at location G. (While this problem is small, you want to devise a method to solve much larger problems).
a) What algorithm would you recommend be used to find the fastest route from the fire station to each of the intersections? Demonstrate how it would work on the example above if the fire station is placed at G. Show the resulting routes.
b) Suppose one ”optimal” location (maybe instead of G) must be selected for the fire station such that it minimizes the distance to the farthest intersection. Devise an algorithm to solve this problem given an arbitrary road map. Analyze the time complexity of your algorithm when there are f possible locations for the fire station (which must be at one of the intersections) and r possible roads.
c) In the above graph what is the “optimal” location to place the fire station? Why?