天天看點

《 Discrete Mathematics and its Applications 》 離散數學及其應用 讀書筆記 ( 三 )

Tree 的作用:

1 Binary Search Tree

2 Decision Tree

3 Prefix code ( Huffman )

1 Binary Search Tree:

簡單來講, 就是先确立一個頂點,然後按大小,從小到大,從左到右的配置設定到這個頂點的兩邊。

《 Discrete Mathematics and its Applications 》 離散數學及其應用 讀書筆記 ( 三 )

2 Decision Tree

在上一篇日志有寫記錄,大概目前的深度也就隻能了解到這一層了。

3 Prefix code

這個應用蠻有意思的。根據某一個單詞,字元出現的頻率大小,用 0 和 1 兩個 bit 來對這個單詞或者字元做編碼,以減少存儲空間,可以用來做資料壓縮。

《 Discrete Mathematics and its Applications 》 離散數學及其應用 讀書筆記 ( 三 )

Tree traversal : 樹的周遊

1 - preorder

2 - inorder

3 - postorder

PreOrder: 從頂點的左邊開始,依次從左到右的順序讀取

《 Discrete Mathematics and its Applications 》 離散數學及其應用 讀書筆記 ( 三 )

InOrder: 從頂點的左邊開始讀,再讀頂點,再讀其他頂點的資料

《 Discrete Mathematics and its Applications 》 離散數學及其應用 讀書筆記 ( 三 )

PostOrder: 從頂點的左邊讀到右邊,再讀頂點

《 Discrete Mathematics and its Applications 》 離散數學及其應用 讀書筆記 ( 三 )

繼續閱讀