TreeLeafCount

TreeLeafCount[tree]

给出 tree 的叶子的数量.

更多信息

范例

打开所有单元关闭所有单元

基本范例  (1)

统计树的叶子的数量:

应用  (1)

随机生成的有 n 个节点的树平均有 n/2 个叶子:

属性和关系  (8)

TreeLeafCount[tree] 等价于 Length[TreeSelect[tree,TreeLeafQ]]

TreeLeafCount[tree] 等价于 Length[TreeLeaves[tree]]

TreeLeafCount[tree] 等价于 TreeCount[tree,_,{-1}]

TreeLeafCount[Tree[{tree1,tree2,}]] 给出 TreeLeafCount[tree1]+TreeLeafCount[tree2]+

TreeLeafCount[Tree[data,None]] 给出 1

TreeLeafCount[Tree[data,{}]] 给出 0

TreeSize[Tree[data,{}]] 给出 1

可用 TreeFold 计算 TreeLeafCount

一般来讲,LeafCount[expr] 等价于 TreeLeafCount[ExpressionTree[expr,"Subexpressions",HeadsTrue]]

一般来讲,LeafCount[expr,HeadsFalse] 等价于 TreeLeafCount[ExpressionTree[expr,"Subexpressions"]]

Wolfram Research (2022),TreeLeafCount,Wolfram 语言函数,https://reference.wolfram.com/language/ref/TreeLeafCount.html.

文本

Wolfram Research (2022),TreeLeafCount,Wolfram 语言函数,https://reference.wolfram.com/language/ref/TreeLeafCount.html.

CMS

Wolfram 语言. 2022. "TreeLeafCount." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/TreeLeafCount.html.

APA

Wolfram 语言. (2022). TreeLeafCount. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/TreeLeafCount.html 年

BibTeX

@misc{reference.wolfram_2024_treeleafcount, author="Wolfram Research", title="{TreeLeafCount}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TreeLeafCount.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_treeleafcount, organization={Wolfram Research}, title={TreeLeafCount}, year={2022}, url={https://reference.wolfram.com/language/ref/TreeLeafCount.html}, note=[Accessed: 22-November-2024 ]}