Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tree 在Ada中寻找二叉树中的叶子_Tree_Binary Search Tree_Ada - Fatal编程技术网

Tree 在Ada中寻找二叉树中的叶子

Tree 在Ada中寻找二叉树中的叶子,tree,binary-search-tree,ada,Tree,Binary Search Tree,Ada,我已经用Ada写了BSt,我正在试着打印叶子。下面是树和节点代码 type Node; type Tree is access Node; type Node is record Item: Integer; Left,Right: Tree; end record; 我可以检查Tree是否为null,但如果我检查Tree.Left或Tree.Right是否为null,我将得到 raised CONSTRAINT_ERROR : access check failed 与…一致

我已经用Ada写了BSt,我正在试着打印叶子。下面是树和节点代码

type Node;
type Tree is access Node;
type Node is record
  Item:  Integer;
  Left,Right:  Tree;
end record;
我可以检查Tree是否为null,但如果我检查Tree.Left或Tree.Right是否为null,我将得到

raised CONSTRAINT_ERROR : access check failed
与…一致

if (T.Left/=null) then

如何检查节点是否没有子节点?

这可能是因为
T
istelf是
null
,并且有一个叶子试试看

如果T/=null,则 如果T.left=null,T.right=null,则
--叶节点

如果
T
null
,则它什么都不是!我认为最好避免使用空指针进行递归调用。假设你是用递归来做的?啊,是的。
T
的父项将是一片叶子,而不是
T
。适合我在精神上对半个书面句子进行修改…呃,可能是一片叶子-只有当
都是