QuickFind

When construct a QuickFind, we pass nn as the capacity of the quick find. We mark the elements in quick find from 00 to n1n-1 (inclusive).

Different algorithms of quick find bring us different growth of the cost, see below:

Type connected(p, q) union(p, q)
tango.type.QuickFind(N) O(1)\text{O}(1) O(N)\text{O}(N)
tango.type.WeightedQuickFind(N) O(lnN)\text{O}(\ln N) O(lnN)\text{O}(\ln N)

connected(p, q): boolean

Returns true iff pp is connected with qq, otherwise false.

count(): number

Gets the number of components which are not connected with each other.

union(p, q): number

Unions pp with qq and returns the count() after union.

results matching ""

    No results matching ""