Cleaned up various DataStructures

This commit is contained in:
Luke Else 2022-04-19 22:00:24 +01:00
parent a8d47f1061
commit c7ccd641c4
2 changed files with 3 additions and 19 deletions

View File

@ -196,7 +196,7 @@ namespace C_.Datastructures.BinaryTree
private TreeNode<T>? GetNext(T value, TreeNode<T>? node) private static TreeNode<T>? GetNext(T value, TreeNode<T>? node)
{//T is comparable so use methods to determine which way to traverse {//T is comparable so use methods to determine which way to traverse
if(node == default) if(node == default)
return default; return default;
@ -214,8 +214,6 @@ namespace C_.Datastructures.BinaryTree
if (Root == default || Root.Value!.Equals(default)) if (Root == default || Root.Value!.Equals(default))
return default; return default;
TreeNode<T>? current = Root;
Stack<TreeNode<T>>? stack = Stack<TreeNode<T>>.Create(Root); Stack<TreeNode<T>>? stack = Stack<TreeNode<T>>.Create(Root);
while (stack.Peek() != default) while (stack.Peek() != default)
@ -229,7 +227,7 @@ namespace C_.Datastructures.BinaryTree
return default; return default;
} }
private Stack<TreeNode<T>>? Min(TreeNode<T>? node) private static Stack<TreeNode<T>>? Min(TreeNode<T>? node)
{//Returns a Stack with the value on top being the minimum of the subtree {//Returns a Stack with the value on top being the minimum of the subtree
if(node == default) if(node == default)
@ -246,7 +244,7 @@ namespace C_.Datastructures.BinaryTree
} }
} }
private Stack<TreeNode<T>>? Max(TreeNode<T>? node) private static Stack<TreeNode<T>>? Max(TreeNode<T>? node)
{///Returns a Stack with the value on top being the maximum of the subtree {///Returns a Stack with the value on top being the maximum of the subtree
if(node == default) if(node == default)
return default; return default;

View File

@ -142,20 +142,6 @@ namespace C_.Datastructures.LinkedList
return node; return node;
} }
//private static LinkedListNode<T>? Traverse(LinkedListNode<T> start){
// //Start at given point in list
// LinkedListNode<T>? node = start;
// if (node != null)
// {
// //Continue to end of list
// while (node!.Next != default)
// {
// node = (LinkedListNode<T>)node.Next;
// }
// }
// return node;
//}
private LinkedListNode<T>? Traverse(int i) private LinkedListNode<T>? Traverse(int i)
{ {
//Start at given point in list //Start at given point in list