Work Note 9, DM206, fall 2008

Exercises November 25

  1. 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?

  2. 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).
  3. 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.
  4. 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.

  5. [K90], problems 10.1, 10.2, 10.3, 10.4.


Last modified: Fri Nov 21 11:08:03 CET 2008
Kim Skak Larsen (kslarsen@imada.sdu.dk)