Incomplete - Tested 'Find' function; Doesn't always return on the given item but instead will continue past it if it has any children
This commit is contained in:
parent
e9df1cab67
commit
735bf68e0d
@ -48,8 +48,13 @@ namespace C_.Datastructures.BinarySearchTree
|
||||
|
||||
}
|
||||
|
||||
public bool Find(T value){
|
||||
var x = Descend(value, Root);
|
||||
return true;
|
||||
}
|
||||
|
||||
private TreeNode<T>? Descend(T value, TreeNode<T>? 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;
|
||||
|
||||
|
@ -111,6 +111,8 @@ tree.Add(1);
|
||||
tree.Add(4);
|
||||
tree.Add(7);
|
||||
|
||||
tree.Find(2);
|
||||
|
||||
|
||||
|
||||
Console.ReadLine();
|
||||
|
Loading…
Reference in New Issue
Block a user