Union-find: Difference between revisions
Jump to navigation
Jump to search
(→unite) |
No edit summary |
||
Line 1: | Line 1: | ||
{{#ev:youtube|https://youtu.be/wE8Y8TU-iUI|500|right|Chapters | |||
#[00:00] Einführung | |||
#[06:27] Wie funktioniert Union-Find nochmal? | |||
#[07:03] Und wie war das noch mit der asymptotischen Komplexität? | |||
|frame}} | |||
== General information == | == General information == | ||
Latest revision as of 13:58, 20 June 2015
General information
Representation invariant:
- There is a nonnegative natural number
, which is constant throughout the lifetime of the object. - At any moment, there is a (dynamically changing) partition of
into non-empty disjoint subsets. Each element of belongs to exactly one of these partition sets. - Each of these subsets
is represented by an arbitrary particular member of , which does not change as long as is one of the partition sets (in other words, as long as is not involved in any call of method unite).
Constructor:
Receives
Find
Input: An element
Output: The element
Precondition: none.
Postcondition: none.
Unite
Input: Two elements,
Output: none.
Precondition: The elements
Postcondition: The subsets to which