Work Note 11, DM206, fall 2010

Exercises December 7

We first look at exercises for Scapegoat Trees (1-5) and then start on exercises for Disjoint Sets (6-10), but we do not expect to finish them all this time.
  1. Argue that a ½-weight-balanced Scapegoat tree has minimal height.
  2. Use illustrations to go through the recursive method for the restructuring of a subtree of a Scapegoat tree which is used in Section 6.1, and make it clear which references must be maintained during the process.
  3. In Scapegoat trees we often need to know the sizes of subtrees. Instead of computing these, we could consider storing these values in the nodes. Consider the pros & cons of this.
  4. One could also register the potential of a node with that node. What could that be used for?
  5. Make a sketch of how the insertion procedure should be coded. Note that there are no parents pointers. Assume that you have the following procedures available: restructure(T) restructures the subtree T and count(T) counts the nodes in the subtree T.
  6. [K90], problems 10.1, 10.2, 10.3, 10.4.
  7. For disjoint sets, show that we obtain the same worst-case complexity as for path compression if we use path splitting (every node on the path is set to point to its grandparent from before the find operation) instead.

    Hint: where in the proof do we use that we apply path compression and how is that knowledge used?

  8. Show that the same complexity is also obtained if we use path halving (every second node on the path is set to point to its grandparent).
  9. Considering programming the various path compression alternatives. Which code is more elegant; the one for compression, splitting, or halving? This is of course somewhat subjective, but offer your opinion.
  10. Show that if we use path compression, but there is no requirement when we combine two trees as a result of a union, then all operations can be shown to be amortized O(log n).

    Use for instance a potential function where the potential is the sum of potentials associated with each node, and each node x has a potential proportional to the logarithm of the size of the tree rooted by x. In the analysis of find, it is essential to distinguish between nodes fulfilling the usual union-by-size criterion and nodes which do not fulfill this criterion.


Last modified: Tue Nov 30 14:11:51 CET 2010
Kim Skak Larsen (kslarsen@imada.sdu.dk)