CSCI 256
Design and analysis of algorithms
Assignment 10

Due Wednesday, 4/25/2001


Only turn in problems from the second section.

Practice problems:

  1. Draw the skip list that results from performing the following sequence of operations on the skip list shown in Figure 3.42 of the skip list handout (taken from "Algorithm Engineering" by Goodrich and Tamassia): removeElement(38), insertItem(48,x), insertItem(24,y), removeelement(55). Assume the coin flips for the first insertion yield two heads followed by tails, while the coin flip for the second insertion yields tails. Note that insertItem(k,val) inserts the value "val" into the dictionary, using k as the key.

    Solution:

       -00                                          00
       -00      17                                  00
       -00      17                                  00
       -00      17          31      42      48      00
       -00  12  17          31      42  44  48      00
       -00  12  17  20  24  31  39  42  44  48  50  00
    
    where -00 should be read as minus infinity and 00 represents infinity.

  2. Problem 27.2-1 on page 599 of the text. In figure 27.1(b), what is the flow across the cut ({s, v2 ,v4},{v1, v3, t})? What is the capacity of this cut?

    Solution: The flow is 19 (= 11 + 1 - 4 +7 + 4). The capacity is 31 (= 16 + 4 + 7 + 4).

Problems to be turned in:

  1. Give a pseudo-code description of the removeElement dictionary operation, assuming the dictionary is implemented by a skip-list structure.

    Solution:

        Algorithm SkipRemove(k)
           p <- SkipSearch(k)
           if key(p) != k then
               return NO_SUCH_KEY
           while p != null
              removeFromHorizList(p)
              p <- above(p)
           return SUCCESS
    where removeFromHorizList(p) is the usual algorithm to remove a node from a doubly linked list (with links before and after).

  2. Problem 27.1-6 on page 586 of the text. Given a flow network G = (V,E), let f1 and f2 be functions from V x V to R. The flow sum f1 + f2 is the function from V x V to R defined by (f1 + f2)(u,v) = f1(u,v) + f2(u,v) for all u, v in V. If f1 and f2 are flows in G, which of the three flow properties must the flow sum f1 + f2 satisfy, and which might it violate?

    Solution:

    1. Capactiy constrint might fail as fi(u,v) <= c(u,v) for i = 1,2 certainly does NOT imply f1(u,v) + f2(u,v) <= c(u,v).
    2. Skew symmetry holds as
           (f1 + f2)(u,v) = f1(u,v) + f2(u,v)
                          = -f1(v,u) - f2(v,u)
                          = - (f1 + f2)(v,u)
      
    3. Flow conservation holds as
       
         (sum of (f1 + f2)(u,v) for all v) 
                = (sum of f1(u,v) for all v) + (sum of f2(u,v) for all v) 
                = 0 + 0


    Back to:

  3. CS256 home page
  4. Kim Bruce's home page
  5. CS Department home page
  6. kim@cs.williams.edu