为了检查二叉搜索树的有效性,我使用了一种方法。但是当针对有效的二叉搜索树进行测试时,该方法总是返回false。
编码
public class Program
{
public static void Main()
{
BinarySearchTree<int> tree = new BinarySearchTree<int>();
tree.Insert(2);
tree.Insert(1);
tree.Insert(3);
Console.WriteLine(tree.IsValidBinarySearchTreeRecursive(tree.root).ToString()); // this is supposed to return true when tested against the simple tree above
}
}
public class Node<T> where T : IComparable
{
public Node<T> left;
public Node<T> right;
public T data;
public Node(T data)
{
this.left = null;
this.right = null;
this.data = data;
}
}
public class BinarySearchTree<T> where T …Run Code Online (Sandbox Code Playgroud) 是否有快捷方式,插件或代码在Notepad ++ 中用引号(""或'')包装文本?
例如"text".
我不懂Python和其他高级编程语言,所以请以简单的方式解释......
我有以下数组:
我需要按照它们的长度对数组进行排序.
如何找出哪一个是最大的,第二大的,第三大的,最小的阵列?
例如,我有以下虚拟函数,可以让我们获得第二大数组:
什么是上面的虚函数算法?
先感谢您
arrays ×1
c# ×1
generics ×1
icomparable ×1
integer ×1
javascript ×1
notepad++ ×1
recursion ×1
regex ×1