Homework 8


Due Date: Nov. 13th (before class)


Assignment

  1. R13.2 (Pg. 654)

    Draw an adjacency list and adjacency matrix representation of the undirected graph shown in Figure 13.1 (Pg. 594).

  2. R13.6 (Pg. 654)

    Suppose we represent a graph G having n vertices and m edges with the edge list structure. Why, in this case, does the insertVertex function run in O(1) time while the eraseVertex function runs in O(m) time?

  3. R13.8 (Pg. 655)

    Would you use the adjacency list structure or the adjacency matrix 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 isAdjacentTo as fast as possible, no matter how much space you use.


Bonus

    C13.4 (Pg. 657)

    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(logn)-time performance for the areAdjacent function. How are you implementing the function in this case? Justify the correctness and complexity of the algorithm.