数据机构Chapm.ppt

数据机构Chapm

Chapter06 Tree and binary tree 要 点 一、了解二叉树的定义、性质和存储结构 二、掌握二叉树的遍历和线索化 三、了解树的定义和存储结构 四、了解树、森林与二叉树转换 五、了解树和森林的遍历 六、了解哈夫曼树及其应用 本章学习的线索 主要线索 重点 树和二叉树的定义及表示 二叉树的遍历 树、森林和二叉树的转换 哈夫曼树和哈夫曼编码 难点 二叉树的遍历及线索化 Contents Definition and notations of Tree and Forest Notations and representation of binary tree Binary tree traversal Threading binary tree Reconstruction of binary tree Transformation among Tree, Forest and binary tree Huffman tree and Huffman coding 6.1 Definition and notations of Tree Examples Discussion Storage structure of tree General list Discussion Storage structure of tree Fixed multiple-branch list Number of branch:tree’s degree Null Pointer? Variable multiple-branch list Number of branch:node’s degree 6.2 Binary tree Examples of binary tree 6.3 storage of binary tree Example Static tri-branch linked list 6.4 Traversal of binary tree 6.4.2 Traversal algorithms Recursive algorithm (递归算法) InOrderTraverse (中序遍历) PreOrderTraverse (先序遍历) PostOrderTraverse (后序遍历) Non-recursive algorithm (非递归算法) InOrderTraverse (中序遍历) PreOrderTraverse (先序遍历) PostOrderTraverse (后序遍历) LevelOrderTraverse (按层次遍历) Inorder traversal Framework of Inorder traversal If binary tree T is NULL, NULL operation else 1) Inorder traverse the left sub-tree 2) Visit root 3) Inorder traverse the right sub-tree Result of Inorder traversal Preorder traversal Framework of Preorder traversal If binary tree T is NULL, NULL operation else Visit root Preorder traverse the left sub-tree Preorder traverse the right sub-tree Result of Inorder traversal Postorder traversal Framework of Postorder traversal If binary tree T is NULL, NULL operation else Postorder traverse the left sub-tree Postorder traverse the right sub-tree Visit root Result of Inorder traversal Other recursive algorithm of binary tree 1、Get the number of node of binary tree (求二叉树的结点个数) Other recursive algorithm of binary tree 2、Get the depth of binary tree (求二叉树的深度) int NumTreeLeaf(PBinTree T ) {//计算以T为根的二叉树的叶子结点个数 if(!T) return 0;

文档评论(0)

1亿VIP精品文档

相关文档