Skip to content

Commit edb0809

Browse files
committed
Fix RB tree position
1 parent de97ce3 commit edb0809

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/Advanced.Algorithms/DataStructures/Tree/RedBlackTree.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private RedBlackTreeNode<T> find(T value)
146146
public int Insert(T value)
147147
{
148148
var node = InsertAndReturnNode(value);
149-
return node.Position;
149+
return Root.Position(value);
150150
}
151151

152152
/// <summary>
@@ -361,7 +361,7 @@ public int Delete(T value)
361361
return -1;
362362
}
363363

364-
var position = node.Position;
364+
var position = Root.Position(value);
365365

366366
delete(node);
367367

src/Advanced.Algorithms/DataStructures/Tree/Shared/BSTNodeBase.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ internal abstract class BSTNodeBase<T> where T : IComparable
1010
//Used to fasten kth smallest computation.
1111
internal int Count { get; set; } = 1;
1212

13-
//position of this node in sorted order of containing BST
14-
internal int Position => Left == null ? 0 : Left.Count;
15-
1613
internal virtual BSTNodeBase<T> Parent { get; set; }
1714

1815
internal virtual BSTNodeBase<T> Left { get; set; }

0 commit comments

Comments
 (0)