我一直在尝试使用类实现二叉搜索树。每次我尝试编译和运行程序时,程序都会结束。我已经尝试了很多东西,比如让* root公开在main中访问它,这样我就可以更新根目录,但不知何故每次都会变为null。 帮助将不胜感激。 这是我的大学项目。 #include <iostream>
using namespace std;
class tree;
class Node {
friend c
我有一种方法来查找二进制搜索树(BST)中的下一个中序继任者。 “inorderSuccessor”方法将BST的任何节点作为输入并输出下一个中间继承者。方法和树类的定义如下: class BSTInorderSuccessor{
public static Node inorderSuccessor(Node node) {
if (node.right != null) {
我是Java的新手,我一直试图实现一个BST,但程序只输出最后插入的值。我对root_node指向哪些方面有错吗?以下是我的源代码Tree.java和Node.java。 Tree.java public class Tree {
private Node root_node;
public void Tree() {
this.root_node = null
作为Haskell的初学者,我目前正试图让我的头绕BST。目前我正在尝试在树上进行折叠。 这是我到目前为止,但它会产生一个错误。 inorder' :: (b -> a -> b) -> b -> BinaryTree a -> b
inorder' _ a myTree = a
inorder' fun a (Node left root right) = inorder' fun (fun