- #1
khdani
- 55
- 0
Hello,
The subject is disjoint set structures
There's following pseudocode for merging sets, by representing every
set as single rooted tree and merging is like merging trees.
It's known that after succesive executions of Merge, the max height of
tree is log(n).
The question is if given 4 trees with 20 nodes, what's the maximum height of
a tree that can be ?
The subject is disjoint set structures
There's following pseudocode for merging sets, by representing every
set as single rooted tree and merging is like merging trees.
Code:
{h[] is array of heights of trees}
Mege(a,b)
if(h[a]==h[b])
set parent of b is a
h[a]++
else if(h[a]>h[b])
set parent of b is a
else
set parent of a is b
It's known that after succesive executions of Merge, the max height of
tree is log(n).
The question is if given 4 trees with 20 nodes, what's the maximum height of
a tree that can be ?