You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Цепляем дерево с меньшим рангом к корню дерева с большим. В этом случае ранг получившегося дерева равен большему, кроме случая, когда ранги равны (тогда будет +1)
67
-
if(rankDifference>0)// у 1-го ранг больше
71
+
// Attach the tree with a smaller rank to the tree with a higher rank.
72
+
// The resulting tree rank is equal to the higher rank
73
+
// except the case when initial ranks are equal.
74
+
// In the latter case the new rank will be increased by 1
75
+
if(rankDifference>0)// 1st has higher rank
68
76
{
69
77
set2Root.ParentIndex=elementOfSet1Index;
70
78
}
71
-
elseif(rankDifference<0)// у 2-го больше
79
+
elseif(rankDifference<0)// 2nd has the higher rank
72
80
{
73
81
set1Root.ParentIndex=elementOfSet2Index;
74
82
}
75
-
else// ранги равны. пофигу что к чему цеплять, но нужно увеличить ранг того, к чему прицепили
83
+
else// ranks are equal and the new root choice is arbitrary
76
84
{
77
85
set2Root.ParentIndex=elementOfSet1Index;
78
86
++set1Root.Rank;
79
87
}
80
88
81
-
// поскольку слили 2 в одно, уменьшаем число сетов
89
+
// we have joined 2 sets, so we have to decrease the count
82
90
--SetsCount;
83
91
}
84
92
}
85
93
86
-
/// <summary>Базовый класс узла дерева</summary>
94
+
/// <summary>Node base class</summary>
87
95
publicclassBasicNode
88
96
{
89
-
/// <summary>Индекс родителя (после компрессии пути указывает на корень)</summary>
97
+
/// <summary>Parent node index</summary>
98
+
/// <remarks>Points to the root after a path compression</remarks>
90
99
publicintParentIndex;
91
100
92
-
/// <summary>Примерный уровень ноды в дереве (с несжатыми путями), считая от корня</summary>
101
+
/// <summary>Estimated height of the tree (i.e. maximum length of the path from the root to a node. Path compression is not taken into account)</summary>
0 commit comments