public int GetMaxRecursive(BstNode currentNode) { if (currentNode.Right == null) return currentNode.Data; var data = GetMaxRecursive(currentNode.Right); return data; }
public int GetMinRecursive(BstNode currentNode) { if (currentNode.Left == null) return currentNode.Data; var data = GetMinRecursive(currentNode.Left); return data; }
public int GetTreeHeight(BstNode currentNode) { if (currentNode == null) return -1; var left = GetTreeHeight(currentNode.Left); var right = GetTreeHeight(currentNode.Right); var max = Math.Max(left, right) + 1; return max; }
public void InOrderTraversal(BstNode currentNode, IList<int?> list) { if (currentNode != null) { PreOrderTraversal(currentNode.Left, list); list.Add(currentNode.Data); PreOrderTraversal(currentNode.Right, list); } }
public static bool IsBinarySearchTree(BinarySearchTree tree, BstNode node, int value) { return false; }
private BstNode DeleteRecursive(BstNode currentNode, int data) { if (currentNode.Data == data) { } return currentNode; }
private void BalanceTree(BstNode node) { }
public int Min(BstNode node, int value) { if (node == null) { return int.MaxValue; } var leftMin = Min(node.Left, node.Data); var rightMin = Min(node.Right, node.Data); var min = Math.Min(leftMin, rightMin); var min2 = Math.Min(min, node.Data); var min3 = Math.Min(min2, value); return min3; }
public BstNode InsertRecursive(BstNode currentNode, int data) { if (currentNode == null) { currentNode = new BstNode { Data = data }; if (Root == null) Root = currentNode; } else if (data <= currentNode.Data) { currentNode.Left = InsertRecursive(currentNode.Left, data); } else if (data > currentNode.Data) { currentNode.Right = InsertRecursive(currentNode.Right, data); } return currentNode; }