⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2 tree identical.txt

📁 It is an ebook about trees
💻 TXT
字号:
Write C code to determine if two trees are identical 

Discuss it!          




struct Bintree{
    int element;
    struct Bintree *left;
    struct Bintree *right;
};

typedef struct Bintree* Tree;

int CheckIdentical( Tree T1, Tree T2 )
{
    if(!T1 && !T2) // If both tree are NULL then return true
        return 1;
    else if((!T1 && T2) || (T1 && !T2)) //If either of one is NULL, return false
        return 0;
    else 
        return ((T1->element == T2->element) && CheckIdentical(T1->left, T2->left) && CheckIdentical(T1->right, T2->right));
        // if element of both tree are same and left and right tree is also same then both trees are same
}
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -