updated tree deletion method
Still not complete but will occasionally delete correctly, seems to have more issues with items near the top of the tree
This commit is contained in:
		@@ -100,9 +100,10 @@ namespace C_.Datastructures.BinaryTree
 | 
			
		||||
                if (node.Value!.CompareTo(parent!.Value) < 0)
 | 
			
		||||
                {//Item being deleted is the left child
 | 
			
		||||
                    parent.Left = default;
 | 
			
		||||
                }else{
 | 
			
		||||
                    //Item being deleted is the right value
 | 
			
		||||
                    parent.Right = default;
 | 
			
		||||
                }
 | 
			
		||||
                //Item being deleted is the right value
 | 
			
		||||
                parent.Right = default;
 | 
			
		||||
            }
 | 
			
		||||
            Count--;
 | 
			
		||||
            return true;
 | 
			
		||||
@@ -214,6 +215,14 @@ namespace C_.Datastructures.BinaryTree
 | 
			
		||||
                return current;
 | 
			
		||||
            }
 | 
			
		||||
            return node;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void ReplaceChild(TreeNode<T> parent, TreeNode<T>? replacement){
 | 
			
		||||
            if (parent.Value!.CompareTo(replacement!.Value) < 0)
 | 
			
		||||
            {//Append to left side
 | 
			
		||||
                parent.Left = replacement;
 | 
			
		||||
            }//Append to right side
 | 
			
		||||
            parent.Right = replacement;
 | 
			
		||||
        } 
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user