Problem 1

The concentric circles of radii are such that for all , and thus may delimit the buckets. Since the expected size of each bucket is due the uniform distribution hypothesis, each call to takes constant time on average, and it follows that runs in time.


Problem 2

Let the hash values of the keys be independent and uniform in . The probability that all are distinct is


Using the bound gives

as required.

The exponent is approximately . If then and rapidly. Thus once passes order the probability of avoiding any collision drops quickly to zero.


Problem 3

Edges have three properties: and are the vertices that connects, and is the weight of . The edge connecting and (that is, such that and or vice versa) may be denoted by . Suppose is a minimum spanning tree of and we decrease the weight of an edge not in . takes as input and the modified edge .

The algorithm works by finding the unique cycle in , and deleting the maximum weighted edge to obtain a new tree .

Suppose is not a minimum spanning tree in the new graph. There must exist another minimum spanning tree with . must contain , since if it didn’t, it would contradict the minimality of with the original weights.

Consider . It has two connected components. There must exist edges in which are not in , since is a tree. Further, there must exist an edge in which connects the two connected components of : If all the edges of connected vertices in the same connected component, it would imply and lie in the same connected component - a contradiction. Thus, is a spanning tree. Now,

Since does not contain , this contradicts the minimality of .

runs in time. Since is a tree, this reduces to for a tree with nodes. The maximum length of the cycle in is for a graph with nodes. Thus, runs in time.


Problem 4

Suppose for every cut of the graph , there exists a unique minimum weight crossing edge . Suppose is a minimum weight spanning tree which does not contain . Consider the graph . Since is a tree, must have exactly one cycle containing . Clearly, must also have an crossing edge which is not . Call this edge . Let . does not contain any cycles, since contained . If connected the vertices and , provides a path between and through . Thus, is connected. Since is the minimum weight crossing edge, has lower weight than , a contradiction. Thus, for every cut , a minimum weight spanning tree must contain the minimum weight crossing edge.

Suppose has vertices. Pick a point and consider the cut . Let be the minimum weight crossing edge. Any minimum weight spanning tree must contain . Next, consider the cut . Let be the minimum weight crossing edge, which again must be contained in any minimum weight spanning tree. Proceeding in this manner, we obtain edges which must be in every minimum weight spanning tree. Since any spanning tree of has exactly edges, this shows that the minimum weight spanning tree of is uniquely determined.

The converse is not true. Consider the following graph:

It has a unique minimum spanning tree, namely, the entire graph, but the cut displayed does not permit a unique minimum weight crossing edge.


Problem 5

uses the identity

Multiplication by powers of can be accomplished by bitshifting in time. Thus, we have the following recurrence:

By the master theorem, .


Problem 6

Let be a fixed point on the circle. We will represent points on the circle by their clockwise angle from , in the range . A chord on the circle connecting points and is denoted by . The chords are supplied as a list . The list is preprocessed such that for each and , which can be done in time. For a chord , we distinguish between its start point and its end point .

accepts a preprocessed list of chords and returns , where is the number of intersections between the chords listed in and is sorted by its second coordinate.

projects the tuples in to their start points: .

Analysis

makes two recursive calls with inputs of size , and spends time doing non-recursive work: merging is , and the membership tests in the for loop can be achieved in time by flagging the elements of , , and with markers prior to merging. Thus, the algorithm runs in time.

Correctness

The algorithm is trivially correct for . For , suppose the algorithm is correct for all . Then, the algorithm correctly computes and , which are the number of pairs of intersecting chords such that both of them lie in and respectively. It remains to compute the number of intersecting pairs where one chord lies in and the other lies in . Suppose and are two such chords. Given our preprocessing of , this happens iff . Thus, for each , it suffices to count the number of chords in which have their end point between and . Equivalently, for each , we can count the number of such that . This is exactly what the for loop does.