public BTreeNode Add(int value) { if (Head == null) { return Head = new BTreeNode() {Value = value}; } return Head.Add(Head, value); }
public BTreeNode Find(BTreeNode current, int value) { if (current == null) return null; if (current.Value == value) return current; if (value < current.Value) return Find(current.Left, value); return Find(current.Right, value); }
public void MoveUp() { _currentRow--; if (_currentNode.Parent.Right != null) { if (_currentNode.Parent.Right.Value == _currentNode.Value) { _currentCol--; } } _currentNode = _currentNode.Parent; }
public void MoveRight() { _currentRow++; _currentCol++; _currentNode = _currentNode.Right; }
public void MoveLeft() { _currentRow++; _currentNode = _currentNode.Left; }
public BTreeNodeMapper(BTreeNode node) { _currentNode = node; _currentCol = 1; _currentRow = 1; }
public BTreeNode Add(BTreeNode current, int value) { if (current.Value == value) { return current; } if (value < current.Value) { if (current.Left == null) { current.Left = new BTreeNode() {Value = value}; current.Left.Parent = current; return current.Left; } else { Add(current.Left, value); } } if (value > current.Value) { if (current.Right == null) { current.Right = new BTreeNode() { Value = value }; current.Right.Parent = current; return current.Right; } else { Add(current.Right, value); } } return null; }