Example #1
0
        internal static void UpdateCounts <T>(this BSTNodeBase <T> node, bool spiralUp = false) where T : IComparable
        {
            while (node != null)
            {
                var leftCount  = node.Left?.Count ?? 0;
                var rightCount = node.Right?.Count ?? 0;

                node.Count = leftCount + rightCount + 1;

                node = node.Parent;

                if (!spiralUp)
                {
                    break;
                }
            }
        }