2. Data structure
1.Path Compression:
Using unthreaded tress, Find takes logarithmic time
and everything else is constant;
Threaded trees, Union takes logarithmic amortized
time and everything else is constant.
A third method allows us to get both of these
operations to have almost constant running time.
We start with the original unthreaded tree
representation, where every object points to a parent.
3. The key observation is that in any Find operation,
once we determine the leader of an object x, we can
speed up future Finds by redirecting x ’ s parent
pointer directly to that leader.
The effect of path compression after find(7) on the
above worst-case tree .
Worst –case tree for N=8
1
2
5
3
4
6
7
8
4. ROUTINE FOR DISJOINT SET FIND WITH PATH
COMPRESSION:
Set Type Find(Element type X , Disjoint S)
{
If(S[X]<=0)
return x:
else
return S[X]=Find(S[X],S)
}
Path compression is a trivial change to the basic find
algorithm. The only change to the find routine is that S[X]
is made equal to the value returned by find , thus after the
root of the set is found recursively , X is made to point
directly to it.
5. •s It has been proven that when path compression is
done , a sequence of M operations required at most
O(M log N) time.
• path compression is perfectly compatible with union
by size. It executes a sequence of M operations in line
time.
•Path compression is not entirely compatible with
union-by size. It executes a sequence of M operations
in line time.
•Path compression is not entirely compatible with
union-by-height , because path compression can
change the heights of the trees.
6. APPLICATION OF SET
Many mathematical concepts can be defined
precisely using only set theoretic concepts. For
example, mathematical structures as diverse
as graphs, manifolds, rings, and vector spaces
can all be defined as sets satisfying various
(axiomatic) properties.
Equivalence and order relations are ubiquitous
in mathematics, and the theory of
mathematical relations can be described in set
theory.
7. Set theory is also a promising foundational system
for much of mathematics. Since the publication of
the first volume of Principia Mathematical,
It has been claimed that most or even all
mathematical theorems can be derived using an
aptly designed set of axioms for set theory,
augmented with many definitions, using first
or second order logic.
For example, properties of the natural and real
numbers can be derived within set theory, as each
number system can be identified with a set
of equivalence classes under a suitable equivalence
relation whose field is some infinite set.
8. Set theory as a foundation for mathematical
analysis, topology, abstract algebra, and discrete
mathematics is likewise uncontroversial;
mathematicians accept that (in principle)
theorems in these areas can be derived from the
relevant definitions and the axioms of set theory.
Few full derivations of complex mathematical
theorems from set theory have been formally
verified, however, because such formal derivations
are often much longer than the natural language
proofs mathematicians commonly present. c
9. One verification project, Met math, includes
human-written, computer‐verified derivations of
more than 12,000 theorems starting from ZFC set
theory, first order logic and propositional logic.
An algorithms to transfer file from any computer
on the network to any other In on-line uses set
concept. The following steps are performed to do
this task,
Initially put every computer in its own test.
10. our invariant is that two computers
can transfer files is an only is they are
in the same set.
the ability to transfer files forms an
equivalence relation.
then connections are read one at a
time say(u , v) and it is tested to see
whether u and v are in the same set
or in different sets.
11. if they are in the same set, nothing is done else
merge there sets.
At the end of the algorithm, the graph is
connected is and only if there is exactly one set.
If there are M connections and N computers, the
space requirements is O(N). Using union-by-size
and path compression , worst-case running time
of O(M &(M,N)) is obtained.
10 10 55 10 10
5
W RE