using System; namespace ALGA { public class BinaryTree { public Node root; public void insert(int number) { if (root == null) { root = new Node(number); return; } root.insert(number); } public void delete(int number) { if (root == null) return; Node node = root.delete(number); if (node == null) root = null; } public bool exists(int number) { if (root == null) return false; return root.find(number) != null; } public int min() { if (root == null) return -1; return root.min().number; } public int max() { if (root == null) return -1; return root.max().number; } public int depth() { if (root == null) return 0; return root.depth(); } public int count() { if (root == null) return 0; return root.count(); } public void print() { if (root == null) return; Console.WriteLine(string.Join(" ", root.flatten())); } public void printInRange(int min, int max) { if (root == null) return; Console.WriteLine(string.Join(" ", root.flatten(min, max))); } } }