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.二叉搜索树的后续遍历数列:

  • 相关阅读:
    js上移、下移排序 效果
    如何为平板打造完美的网站页面?
    [BUUOJ]刮开有奖reverse
    [0CTF 2016]piapiapia
    [TSCTFJ 2019]bypass
    [安洵杯 2019]easy_serialize_php
    [TSCTFJ] relax
    c#访问网页
    DNN 数据访问
    c#访问数据库
  • 原文地址:https://www.cnblogs.com/mmziscoming/p/5757115.html
Copyright © 2011-2022 走看看