亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? binarytree.h

?? C++編成數據結構與程序設計方法 D.S.Malk編著
?? H
字號:
//Header File Binary Search Tree
#ifndef H_binaryTree
#define H_binaryTree

#include <iostream>

using namespace std;

    //Definition of the Node
template <class elemType>
struct nodeType
{
    elemType info;
    nodeType<elemType> *lLink;
    nodeType<elemType> *rLink;
};
	
    //Definition of the class
template <class elemType>
class binaryTreeType
{
public:
    const binaryTreeType<elemType>& operator=
                 (const binaryTreeType<elemType>&); 
      //Overload the assignment operator.

    bool isEmpty() const;
      //Function to determine whether the binary tree is empty.
      //Postcondition: Returns true if the binary tree is empty;
      //               otherwise, returns false.

    void inorderTraversal() const;
      //Function to do an inorder traversal of the binary tree.
      //Postcondition: Nodes are printed in inorder sequence.

    void preorderTraversal() const;
      //Function to do a preorder traversal of the binary tree.
      //Postcondition: Nodes are printed in preorder sequence.

    void postorderTraversal() const;
      //Function to do a postorder traversal of the binary tree.
      //Postcondition: Nodes are printed in postorder sequence.

    int treeHeight() const;
      //Function to determine the height of a binary tree.
      //Postcondition: Returns the height of the binary tree.

    int treeNodeCount() const;
      //Function to determine the number of nodes in a 
      //binary tree.
      //Postcondition: Returns the number of nodes in the 
      //               binary tree.

    int treeLeavesCount() const;
      //Function to determine the number of leaves in a 
      //binary tree.
      //Postcondition: Returns the number of leaves in the 
      //               binary tree.

    void destroyTree();
      //Function to destroy the binary tree.
      //Postcondition: Memory space occupied by each node 
      //               is deallocated.
      //               root = NULL;

    virtual bool search(const elemType& searchItem) const = 0;
      //Function to determine if searchItem is in the binary 
      //tree.
      //Postcondition: Returns true if searchItem is found in 
      //               the binary tree; otherwise, returns 
      //               false.

    virtual void insert(const elemType& insertItem) = 0;
      //Function to insert insertItem in the binary tree.
      //Postcondition: If there is no node in the binary tree
      //               that has the same info as insertItem, a
      //               node with the info insertItem is created
      //               and inserted in the binary search tree.

    virtual void deleteNode(const elemType& deleteItem) = 0;
      //Function to delete deleteItem from the binary tree 
      //Postcondition: If a node with the same info as 
      //               deleteItem is found, it is deleted from
      //               the binary tree.
      //               If the binary tree is empty or 
      //               deleteItem is not in the binary tree, 
      //               an appropriate message is printed.

    binaryTreeType(const binaryTreeType<elemType>& otherTree); 
      //Copy constructor

    binaryTreeType();   
      //Default constructor

    ~binaryTreeType();   
      //Destructor

protected:
    nodeType<elemType>  *root;

private:
    void copyTree(nodeType<elemType>* &copiedTreeRoot,
                  nodeType<elemType>* otherTreeRoot);
      //Makes a copy of the binary tree to which 
      //otherTreeRoot points. 
      //Postcondition: The pointer copiedTreeRoot points to
      //               the root of the copied binary tree.

    void destroy(nodeType<elemType>* &p);
      //Function to destroy the binary tree to which p points. 
      //Postcondition: Memory space occupied by each node, in 
      //               the binary tree to which p points, is 
      //               deallocated.
      //               p = NULL;

    void inorder(nodeType<elemType> *p) const;
      //Function to do an inorder traversal of the binary
      //tree to which p points.  
      //Postcondition: Nodes of the binary tree, to which p
      //               points, are printed in inorder sequence.

    void preorder(nodeType<elemType> *p) const;
      //Function to do a preorder traversal of the binary
      //tree to which p points.  
      //Postcondition: Nodes of the binary tree, to which p
      //               points, are printed in preorder 
      //               sequence.

    void postorder(nodeType<elemType> *p) const;
      //Function to do a postorder traversal of the binary
      //tree to which p points.  
      //Postcondition: Nodes of the binary tree, to which p
      //               points, are printed in postorder 
      //               sequence.

    int height(nodeType<elemType> *p) const;
      //Function to determine the height of the binary tree
      //to which p points. 
      //Postcondition: Height of the binary tree to which 
      //               p points is returned.

    int max(int x, int y) const;
      //Function to determine the larger of x and y.
      //Postcondition: Returns the larger of x and y.

    int nodeCount(nodeType<elemType> *p) const;
      //Function to determine the number of nodes in 
      //the binary tree to which p points. 
      //Postcondition: The number of nodes in the binary 
      //               tree to which p points is returned.

    int leavesCount(nodeType<elemType> *p) const;
      //Function to determine the number of leaves in  
      //the binary tree to which p points 
      //Postcondition: The number of leaves in the binary 
      //               tree to which p points is returned.
};

	//Definition of member functions

template <class elemType>
binaryTreeType<elemType>::binaryTreeType()
{
    root = NULL;
}

template <class elemType>
bool binaryTreeType<elemType>::isEmpty() const
{
    return (root == NULL);
}

template <class elemType>
void binaryTreeType<elemType>::inorderTraversal() const
{
    inorder(root);
}

template <class elemType>
void binaryTreeType<elemType>::preorderTraversal() const
{
    preorder(root);
}

template <class elemType>
void binaryTreeType<elemType>::postorderTraversal() const
{
    postorder(root);
}

template <class elemType>
int binaryTreeType<elemType>::treeHeight() const
{
    return height(root);
}

template <class elemType>
int binaryTreeType<elemType>::treeNodeCount() const
{
    return nodeCount(root);
}

template <class elemType>
int binaryTreeType<elemType>::treeLeavesCount() const
{
    return leavesCount(root);
}

template <class elemType>
void  binaryTreeType<elemType>::copyTree
                       (nodeType<elemType>* &copiedTreeRoot,
                        nodeType<elemType>* otherTreeRoot)
{
    if (otherTreeRoot == NULL)
        copiedTreeRoot = NULL;
    else
    {
        copiedTreeRoot = new nodeType<elemType>;
        copiedTreeRoot->info = otherTreeRoot->info;
        copyTree(copiedTreeRoot->lLink, otherTreeRoot->lLink);
        copyTree(copiedTreeRoot->rLink, otherTreeRoot->rLink);
    }
} //end copyTree

template <class elemType>
void binaryTreeType<elemType>::inorder
                              (nodeType<elemType> *p) const
{
    if (p != NULL)
    {
        inorder(p->lLink);
        cout << p->info << " ";
        inorder(p->rLink);
    }
}

template <class elemType>
void binaryTreeType<elemType>::preorder
                              (nodeType<elemType> *p) const
{
    if (p != NULL)
    {
        cout << p->info << " ";
        preorder(p->lLink);
        preorder(p->rLink);
    }
}

template <class elemType>
void binaryTreeType<elemType>::postorder
                              (nodeType<elemType> *p) const
{
    if (p != NULL)
    {
        postorder(p->lLink);
        postorder(p->rLink);
        cout << p->info << " ";
    }		
}

   //Overload the assignment operator
template <class elemType>
const binaryTreeType<elemType>& binaryTreeType<elemType>::
        operator=(const binaryTreeType<elemType>& otherTree)
{ 
    if (this != &otherTree) //avoid self-copy
    {
        if (root != NULL)   //if the binary tree is not empty,
                            //destroy the binary tree
            destroy(root);

        if (otherTree.root == NULL) //otherTree is empty
            root = NULL;
        else
            copyTree(root, otherTree.root);
    }//end else

    return *this; 
}

template <class elemType>
void  binaryTreeType<elemType>::destroy(nodeType<elemType>* &p)
{
    if (p != NULL)
    {
        destroy(p->lLink);
        destroy(p->rLink);
        delete p;
        p = NULL;
    }
}

template <class elemType>
void  binaryTreeType<elemType>::destroyTree()
{
    destroy(root);
}

	//copy constructor
template <class elemType>
binaryTreeType<elemType>::binaryTreeType
                (const binaryTreeType<elemType>& otherTree)
{
    if (otherTree.root == NULL) //otherTree is empty
        root = NULL;
    else
        copyTree(root, otherTree.root);
}

    //Destructor
template <class elemType>
binaryTreeType<elemType>::~binaryTreeType()
{
    destroy(root);
}

template<class elemType>
int binaryTreeType<elemType>::height
                             (nodeType<elemType> *p) const
{
    if (p == NULL)
        return 0;
    else
        return 1 + max(height(p->lLink), height(p->rLink));
}

template <class elemType>
int binaryTreeType<elemType>::max(int x, int y) const
{
    if (x >= y)
        return x;
    else
        return y;
}

template <class elemType>
int binaryTreeType<elemType>::nodeCount(nodeType<elemType> *p) const
{
    cout << "Write the definition of the function nodeCount."
         << endl;

    return 0;
}

template <class elemType>
int binaryTreeType<elemType>::leavesCount(nodeType<elemType> *p) const
{
    cout << "Write the definition of the function leavesCount."
         << endl;

    return 0;
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲精品一区二区精品久久久 | 国产日韩欧美综合一区| 在线一区二区三区四区五区| 久久国产视频网| 亚洲18女电影在线观看| 亚洲精品中文在线观看| 亚洲精品国产一区二区精华液| 国产欧美日韩在线看| 国产农村妇女精品| 国产精品丝袜黑色高跟| 综合分类小说区另类春色亚洲小说欧美 | 国产精品一线二线三线| 黄色小说综合网站| 国产精品99久久久久久有的能看 | 精品国产区一区| 欧美精品丝袜中出| 91精品国产色综合久久| 欧美一区二区三区在| 欧美久久久久久久久中文字幕| 欧美日韩一区在线观看| 欧美日韩成人在线一区| 日韩精品一区二区三区四区| 91精品视频网| 91精品国产美女浴室洗澡无遮挡| 欧美变态tickling挠脚心| 国产喂奶挤奶一区二区三区| 国产精品免费久久| 一区二区三区国产精华| 免费成人小视频| 国产精品性做久久久久久| 91女厕偷拍女厕偷拍高清| 欧美日韩夫妻久久| 中文字幕免费观看一区| 亚洲小说欧美激情另类| 免费久久精品视频| 国产suv精品一区二区6| 欧美日韩一区二区三区四区| 欧美精品黑人性xxxx| 国产三级欧美三级日产三级99| 久久久99精品久久| 亚洲精品你懂的| 国产一区二区日韩精品| 99久久精品免费看国产免费软件| 欧美三级电影网| 国产一区在线视频| 亚洲视频香蕉人妖| 男人的j进女人的j一区| 亚洲午夜久久久久中文字幕久| 国产酒店精品激情| 亚洲成a人在线观看| 国产精品免费看片| 欧美一区二区视频在线观看2022| 337p亚洲精品色噜噜狠狠| 欧美激情综合网| 1024国产精品| 欧美性欧美巨大黑白大战| 欧美日韩一区视频| 亚洲少妇30p| 国内不卡的二区三区中文字幕 | 精品国产91乱码一区二区三区 | 国产欧美日韩久久| 秋霞国产午夜精品免费视频| 国产高清不卡一区| 欧美三级视频在线| 日韩三区在线观看| 一区二区三区丝袜| 成人一区二区在线观看| 精品国产1区二区| 精品一区二区三区影院在线午夜| 欧美人与z0zoxxxx视频| 综合网在线视频| 91视频你懂的| 国产精品嫩草影院av蜜臀| 国产精品综合二区| 欧美一级二级在线观看| 尤物视频一区二区| 在线看国产日韩| 一区二区三区欧美亚洲| av亚洲产国偷v产偷v自拍| 日韩午夜激情av| 亚洲图片自拍偷拍| 成人黄色小视频| 国产综合一区二区| 精品美女一区二区| 国产黄色精品视频| 国产精品第四页| 国内精品在线播放| 精品国产免费人成电影在线观看四季| 无码av免费一区二区三区试看| 欧美三级中文字幕在线观看| 亚洲v精品v日韩v欧美v专区| 欧美日韩国产高清一区二区三区| 日韩1区2区日韩1区2区| 欧美电视剧在线看免费| 国产**成人网毛片九色| 综合久久给合久久狠狠狠97色| 色哟哟在线观看一区二区三区| 亚洲一区二区高清| 日韩午夜在线影院| 99精品国产视频| 午夜欧美电影在线观看| 91精品国产综合久久久蜜臀粉嫩| 免费不卡在线观看| 国产精品亲子乱子伦xxxx裸| 国内外成人在线| 久久午夜色播影院免费高清| 粉嫩aⅴ一区二区三区四区| 中文字幕制服丝袜成人av| 91成人免费在线视频| 水野朝阳av一区二区三区| 久久久久久久综合日本| 一本到三区不卡视频| 六月婷婷色综合| 精品国产青草久久久久福利| 94-欧美-setu| 狠狠色丁香婷综合久久| 中文在线一区二区| 色八戒一区二区三区| 麻豆视频一区二区| 亚洲国产你懂的| 国产精品久久久久三级| 欧美tickling网站挠脚心| 欧美性受xxxx黑人xyx| 国产精品一区二区久激情瑜伽| 亚洲小说欧美激情另类| 中文在线一区二区| 久久亚洲综合色一区二区三区| 国产传媒一区在线| 看电影不卡的网站| 亚洲另类色综合网站| 欧美精品一区二区在线播放| 欧美日韩欧美一区二区| 99麻豆久久久国产精品免费 | 国产精品色婷婷久久58| 欧美猛男男办公室激情| 成人99免费视频| 秋霞午夜鲁丝一区二区老狼| 亚洲欧美一区二区三区孕妇| 久久综合中文字幕| 亚洲精品一区二区三区蜜桃下载| 9191国产精品| 欧美高清性hdvideosex| 欧美性三三影院| 91国产免费观看| 国产高清在线精品| 国产精品主播直播| 经典三级视频一区| 狂野欧美性猛交blacked| 日本成人在线一区| 亚洲va韩国va欧美va| 性久久久久久久久久久久| 亚洲国产另类精品专区| 亚洲国产精品欧美一二99| 亚洲影院久久精品| 天天影视涩香欲综合网| 亚洲尤物在线视频观看| 亚洲精品乱码久久久久久黑人| 亚洲色图19p| 亚洲九九爱视频| 亚洲成人精品影院| 美女视频网站黄色亚洲| 国产一区免费电影| 国产成人在线影院| 99久久精品国产一区| 一本色道久久加勒比精品| 在线观看区一区二| 538prom精品视频线放| 日韩欧美色综合| 欧美国产成人精品| 国产精品久久久99| 中文字幕亚洲视频| 天堂影院一区二区| 国产精品69毛片高清亚洲| 成人99免费视频| 欧美精品1区2区| 久久精品一区二区| 亚洲精品福利视频网站| 日韩精品电影在线观看| 激情综合亚洲精品| 色综合亚洲欧洲| 欧美精品一区二区三区一线天视频| 久久久久久久久99精品| 国产精品乱码一区二区三区软件| 亚洲欧洲中文日韩久久av乱码| 日韩主播视频在线| 成人天堂资源www在线| 色屁屁一区二区| 日韩欧美黄色影院| 亚洲欧美日韩国产手机在线| 美女一区二区三区在线观看| 国产精品1024| 国产传媒日韩欧美成人| 欧洲亚洲精品在线| 欧美激情一区二区三区蜜桃视频| 亚洲精品成人少妇| 国产高清在线观看免费不卡| 欧美精品日韩综合在线| 日韩一区二区三区四区| 日韩美女视频19| 国产成人午夜精品影院观看视频 |