【算法導論】決策樹是滿二叉樹嗎?

今天看《算法導論》第三版中文版第八章,文中說“決策樹是一顆完全二叉樹”,再看看右邊的配圖:


我當時就懵了,學了幾年數據結構,也沒看過有這樣的完全二叉樹啊,按常理完全二叉樹應該倒數第二層是滿的,最後一層的葉子是從左到右開始排的啊,所以上圖明顯不符合完全二叉樹的定義。

後來我想,都聽說第三版的翻譯很爛,是不是翻譯出錯了,於是查看英文原文如下:


“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個子節點”,根據這個定義,《算法導論》上說決策樹是滿二叉樹也沒有錯!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章