CSCE 221: Data Structures and Algorithms

Sections: 507, 508, 509
Fall 2015



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.


Grading Rubric

Each homework composes 2% of your final grade. Each homework will be graded out of 100 possible points. In any problem asking you to design an algorithm please also provide proper pseudocode (mathematical notation), complexity analysis (both space and time), and brief justification of complexity and correctness.

All assignments must be turned in with a signed coverpage. If no coverpage is provided, the assignment will not be graded.

If there are any discrepancies in grades please see Jory Denny during his office hours (not the TA or Grader).