【算法导论】决策树是满二叉树吗?

今天看《算法导论》第三版中文版第八章,文中说“决策树是一颗完全二叉树”,再看看右边的配图:

《【算法导论】决策树是满二叉树吗?》

我当时就懵了,学了几年数据结构,也没看过有这样的完全二叉树啊,按常理完全二叉树应该倒数第二层是满的,最后一层的叶子是从左到右开始排的啊,所以上图明显不符合完全二叉树的定义。

后来我想,都听说第三版的翻译很烂,是不是翻译出错了,于是查看英文原文如下:

《【算法导论】决策树是满二叉树吗?》

“A decision tree is a full binary tree…”一个决策树是满二叉树!

再仔细想想,满二叉树也不对啊,满二叉树首先是完全二叉树,而且满二叉树的最后一层是满的,也就是说叶子都是在最后一层的。

难道是这本书出错了?不可能吧,好歹也到了第三版,这么多人用,如果真的出错,也不至于到现在还没更正啊,于是再次查看满二叉树(full binary tree)的定义。

中文百度百科关于”满二叉树“上有这么一段话

美国以及国际上所定义的满二叉树,即full binary tree,和国内的定义不同,美国NIST给出的定义为:A binary tree in which each node has exactly zero or two children. In other words, every node is either a leaf or has two children. For efficiency, any Huffman coding is a full binary tree.
满二叉树的任意节点,要么度为0,要么度为2.换个说法即要么为叶子结点,要么同时具有左右孩子。霍夫曼树是符合这种定义的,满足国际上定义的满二叉树,但是不满足国内的定义.

再看英文wiki上关于“Binary tree”的介绍:

  • full binary tree or proper binary tree [17] (sometimes 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children. Physicists define a binary tree to mean a full binary tree.[18]  《【算法导论】决策树是满二叉树吗?》 《【算法导论】决策树是满二叉树吗?》 An  ancestry chart which maps to a perfect depth-4 binary tree . A full tree is sometimes ambiguously defined as a perfect tree (see next).
  • perfect binary tree is a full binary tree in which all leaves have the same depth or same level, and in which every parent has two children.[19] (This is ambiguously also called a complete binary tree (see next).) An example of a perfect binary tree is the ancestry chart of a person to a given depth, as each person has exactly two biological parents (one mother and one father); note that this reverses the usual parent/child tree convention, and these trees go in the opposite direction from usual (root at bottom).

原来是国内和国际上关于满二叉树的定义不一样啊,国内认为的满二叉树其实就是英文wiki上说的”perfect binary tree”,而其认为的满二叉树只要满足“一个节点要么是叶子节点,要么有2个子节点”,根据这个定义,《算法导论》上说决策树是满二叉树也没有错!

    原文作者:满二叉树
    原文地址: https://blog.csdn.net/cjmcp/article/details/38534133
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞