zoukankan      html  css  js  c++  java
  • 二叉树知识点整理

    概念:

    struct BinaryTree

    {

    int value;

    BinaryTree*pright;

    BinaryTree*pleft;

    }

    满二叉树 完全二叉树 二叉搜索树

    编程题:

    实现二叉树的遍历:

    递归的算法实现二叉树的遍历:

    题一:树的子结构:

    vool hassubtree(BinaryTree *root1,BinaryTree 8root2)

    {

    bool result=false;

    if(root1!=NULL&&root2!=NULL)

    {

    if(root1->value==root2->value)

    {

    result=Dosubtree(root1,toot2);

    }

    if (!result)

    {

    result=hassubtree(root1->left,root2);

    }

    if(!result)

    {

    result=hassubtree(root1->right,root2);

    }

    return result;

    }

    }

    bool Dosubtree(BinaryTree *root1,BinaryTree 8root2)

    {

    if(root1->left==root2->left&&root1->right==root2->right)

     return true;

    }

    2.二叉树的镜像:

    void reverse(Binarysearch *root)

    {

    //判断:

    if(root==NULL||root->left==BULL&&root->right==NULL)

    {

    return;

    }

    Binarysearch*ptemp=root->left;

    root->left=p->right;

    p->right=p->temp;

    reverse(p->left);

    reverse(p->right);

    }

    3.二叉搜索树的后续遍历数列:

  • 相关阅读:
    PAT 1032 (未完成)
    PAT 1031
    PAT 1030
    将爬取到的数据存入数据框并导出
    XPath常见用法
    python 图表
    Protobuf在Unity中的通讯使用
    ProtoBuf在Unity中的使用
    Unity更新资源代码
    匿名函数
  • 原文地址:https://www.cnblogs.com/mmziscoming/p/5757115.html
Copyright © 2011-2022 走看看