所以我应该编写一个程序在二叉搜索树中打印第k个最小的元素。这是我的代码。可悲的是,我一直盯着我的代码45分钟,我似乎无法找到我的错误。有人可以帮我吗? let res;
function kthLargestInBST(t, k) {
helper(t, k, 1);
return res;
}
function helper(t, k, curr) {
i
我有一种方法来查找二进制搜索树(BST)中的下一个中序继任者。 “inorderSuccessor”方法将BST的任何节点作为输入并输出下一个中间继承者。方法和树类的定义如下: class BSTInorderSuccessor{
public static Node inorderSuccessor(Node node) {
if (node.right != null) {