数据结构期末 树和图

基本概念

1.最多一个先驱 但可能有多个后继 表示具有层次的分支关系

2.Siblings(兄弟): nodes share the same parent

Degree(树的扇出) of a tree: the maximum number of its node.

3.深度为最大层数 

第i层最多2^i个结点

4.完全二叉树:满二叉树去掉最下面一层最右边若干节点

完全二叉树深度 log2(n)向下取整

第i个结点 左孩子2i+1 右孩子2i+2

父结点(i-1)/2

5.preorder(TreeNode * root){

if(root!=NULL){

cout<<root->val<<endl;

preorder(root->left);

preorder(root->right);}

inorder(TreeNode * root){

if(root!=NULL){

inorder(root->left);

cout<<root->value<<endl;

inorder(root->right);}

postorder

6.

猜你喜欢

转载自www.cnblogs.com/wwqdata/p/12116578.html
今日推荐