static void Main(string[] args) { Bogyo root = new Bogyo(0); BaszoTree tree = new BaszoTree(root); tree.Add(10); tree.Add(1); tree.Add(15); tree.Add(16); tree.Add(111); tree.Add(4); Console.WriteLine(tree.CheckRecursive(root, 16)); Console.ReadKey(); }
public Bogyo Recursive(Bogyo bogyo, int value) { if (bogyo == null) { return(new Bogyo(value)); } else if (value >= bogyo.Value) { return(Recursive(bogyo.right, value)); } else if (value < bogyo.value) { return(Recursive(bogyo.left, value)); } }
public bool CheckRecursive(Bogyo bogyo, int cucc) { if (bogyo != null) { if (root.Value == cucc) { return(true); } else { if (CheckRecursive(bogyo.Left, cucc)) { return(true); } if (CheckRecursive(bogyo.Right, cucc)) { return(true); } } } return(false); }
public BaszoTree(Bogyo root) { this.root = root; }
public Bogyo(int value) { this.value = value; left = null; right = null; }