From 735bf68e0d8474afcb1882f0695a85a537f38e91 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 8 Apr 2022 22:35:55 +0100 Subject: [PATCH] Incomplete - Tested 'Find' function; Doesn't always return on the given item but instead will continue past it if it has any children --- C#/Datastructures/BinarySearchTree/Tree.cs | 7 ++++++- C#/Program.cs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/C#/Datastructures/BinarySearchTree/Tree.cs b/C#/Datastructures/BinarySearchTree/Tree.cs index 8fadc48..e97ac61 100644 --- a/C#/Datastructures/BinarySearchTree/Tree.cs +++ b/C#/Datastructures/BinarySearchTree/Tree.cs @@ -48,8 +48,13 @@ namespace C_.Datastructures.BinarySearchTree } + public bool Find(T value){ + var x = Descend(value, Root); + return true; + } + private TreeNode? Descend(T value, TreeNode? current) - {//Keep trying to determine whether to go left or right until null node is found + {//Keep trying to determine whether to go left or right until null node is found that can be appended to if (current == default) return default; diff --git a/C#/Program.cs b/C#/Program.cs index 1aa0b1d..d4b046f 100644 --- a/C#/Program.cs +++ b/C#/Program.cs @@ -111,6 +111,8 @@ tree.Add(1); tree.Add(4); tree.Add(7); +tree.Find(2); + Console.ReadLine();