2/11/98 day 10 Qoute of the day, ``Someone has to be bigger than the other.''

1.  Union find

1.1  operations

used by Kruskal's algorithm

1.2  implementation

Have a large array (one entry per element) which points towards a representative member of each equivalence class. Each equivalence class has some root representative member.

1.2.1 implementing union

Union is implemented by linking the root of one tree to the root of another tree.

Improvement: (weighted union) Link the smaller tree to the larger tree to improve balance. It's necessary to keep along a 'size' field.

1.2.2 find

Recurse towards the root and return the root.

Improvement: (path compression) When you find the representative from an element, adjust every pointer in the path to point directly towards the root.

1.3  analysis

1.3.1 Tree height limitation

Let T, a tree. height(T)=#edge on max length path

lemma: with weighted union |T| ³ 2height(T)

proof: assume |T1| ³ 2h(T1) , |T2| ³ 2h(T2) and without loss of generality |T1| ³ |T2|

T = union(T1,T2) .

case 1: height(T) = height(T1) . Ok, because the height hasn't increased while the size has.

tcase 2: height(T) = 1+height(T2) . Ok, because 21+height(T2) = 2*2height(T2) £ 2*|T2| £ |T2|+|T1| = |T|

1.3.2 Ackermann function

This is pretty fast.

Now, define the ackermann function as A(k) = Ak(2) .

Define the inverse Ackermann as: a(n) = min{k:A(k) ³ n} . This grows pretty slow.

1.3.3 union find analysis

Rank increases while a node is a root, but never increases when it is not a root.

define: 0 £ d(u) = max{k|rank(parent(u)) ³ A(rank(u)) . Then for n ³ 5 , d(n) £ a(n)

'Find' has a(n) cost because it can only be charged once for each value of d.

let x' = parent(x), v = root

If x gets rank(x) charges then d(x) increases. This means it can in incur at most rank(x)a(n) charges. This is a rather large number in comparison to a(n) but we are save by the lemma limiting the number of nodes at a particular rank.

total charges < åi = 1log(n)ra(n)([(n)/( 2r-2)]) £ na(n)åi = 1infinity[(r)/( 2r-2)] = O(na(n))

This means with m union-finds on a set of size n, the timing is O((m+n)a(n))


File translated from TEX by TTH, version 1.30.