Homework Assignment 8


Due: Apr. 6 before class starts


Assignment

  1. (40 points) Draw an adjacency list and adjacency matrix representation of the undirected graph shown in Figure 14.1.
  2. (30 points) Suppose we represent a graph G having n vertices and m edges with the edge list structure. Why, in this case, does the insertVertex method run in O(1) time while the removeVertex method runs in O(m) time? Statement and proof of complexity required.
  3. (30 points) Would you use the adjacency matrix structure or the adjacency list structure in each of the following cases? Justify your choice.
    1. The graph has 10,000 vertices and 20,000 edges, and it is important to use as little space as possible.
    2. The graph has 10,000 vertices and 20,000,000 edges, and it is important to use as little space as possible.
    3. You need to answer the query getEdge(u, v) as fast as possible, no matter how much space you use.
  4. Bonus. (10 points) Suppose we wish to represent an n-vertex graph G using the edge list structure, assuming that we identify the vertices with the integers in the set {0, 1, ..., n - 1}. Describe how to implement the collection E to support O(log n)-time performance for the getEdge(u, v) method. How are you implementing the method in this case?


General Instructions, Turning in assignments, and Grading

General Instructions

Turn in Instructions

Each assignment will be turned in in class (hard copy). Assignments are due BEFORE, let me repeat, before class starts. This does not mean five minutes after class starts. Details:

Points