So I'm making a Binary Search tree in C#, and I'm having some troubles with my delete method. I'm pretty sure the algorithm works (The concept) but whenever I compile I get 2 errors, and I'm not sure why.
Note: I'm not use to C#, I've only been using it for about 1 day now.
Here is the delete method:
The 2 errors I keep getting are:Code:private void Delete( t data, Node<t> reference ) { int c = data.CompareTo( reference.data ); if ( c < 0 || c > 0 ) { if ( reference.left.data == data || reference.right.data == data ) { if ( reference.left.left != null ) reference.left = reference.left.left; else if ( reference.left.left == null && reference.left.right != null ) reference.left = reference.left.right; else reference.left = null; } else Delete( data, reference.left ); } }
The line that it's referring to is:Code:Error 1 Operator '==' cannot be applied to operands of type 't' and 't' Line: 83 Error 2 Operator '==' cannot be applied to operands of type 't' and 't' Line: 83
If you want to see the rest of the code you can go here: http://rafb.net/p/UZm4F669.htmlCode:if ( reference.left.data == data || reference.right.data == data ) {
Thanks.



LinkBack URL
About LinkBacks


