亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
中文字幕一区二区日韩精品绯色| 成人亚洲一区二区一| 久国产精品韩国三级视频| 91玉足脚交白嫩脚丫在线播放| 日韩女优视频免费观看| 夜夜精品浪潮av一区二区三区 | 久久久久久97三级| 亚洲高清久久久| 99久久久久免费精品国产| 精品国产乱码久久久久久夜甘婷婷| 亚洲免费av网站| 国产乱子伦一区二区三区国色天香| 欧美三级日本三级少妇99| 国产精品国产三级国产aⅴ无密码| 日韩成人伦理电影在线观看| 色系网站成人免费| 中文字幕在线免费不卡| 成人自拍视频在线观看| 久久久国产精品不卡| 精品一区二区影视| 制服丝袜亚洲播放| 香港成人在线视频| 在线观看三级视频欧美| 亚洲日本一区二区| 在线亚洲+欧美+日本专区| 亚洲欧美日本韩国| 一本大道久久a久久综合| 中文字幕在线不卡一区二区三区| 国产91精品在线观看| 亚洲国产高清在线观看视频| 成人免费毛片嘿嘿连载视频| 国产精品天天摸av网| 国产成人精品影院| 国产精品短视频| 91麻豆.com| 亚洲成人综合视频| 欧美一级片免费看| 九九九久久久精品| 国产午夜精品一区二区三区嫩草| 国产成人免费视频网站 | 亚洲精品一区二区三区四区高清 | 六月丁香综合在线视频| 欧美日本韩国一区二区三区视频 | 精品欧美乱码久久久久久1区2区| 日本伊人精品一区二区三区观看方式| 欧美日韩一区二区三区视频| 亚洲综合小说图片| 欧美一区二区三区喷汁尤物| 韩国视频一区二区| 中文字幕在线不卡视频| 欧美探花视频资源| 国产原创一区二区三区| 最新国产成人在线观看| 欧美中文字幕一区二区三区| 免费的成人av| 国产精品色在线观看| 91福利在线看| 久久91精品国产91久久小草| 中文字幕在线观看不卡| 欧美日本在线视频| 国产精品中文有码| 亚洲国产日韩一级| 国产色婷婷亚洲99精品小说| 日本韩国欧美一区二区三区| 蜜臀va亚洲va欧美va天堂| 中文字幕高清不卡| 9191国产精品| 福利电影一区二区三区| 天天综合天天综合色| 国产精品久久久久婷婷二区次| 欧美色大人视频| 成人免费观看视频| 美女网站一区二区| 亚洲一级二级在线| 国产精品无人区| 欧美岛国在线观看| 欧美日韩激情一区二区| 成人av网站在线| 精品一区二区三区蜜桃| 亚洲第一会所有码转帖| 亚洲欧洲成人自拍| 久久久国产精华| 欧美一级一区二区| 欧美日韩一区高清| 色综合视频在线观看| 国产成人免费在线观看| 久久99久久99精品免视看婷婷| 一区二区三区在线免费| 国产精品福利电影一区二区三区四区| 日韩欧美区一区二| 91精品国产乱| 欧美视频日韩视频| 欧美在线视频全部完| 波多野结衣91| 成人午夜看片网址| 国产成人在线观看| 激情图片小说一区| 精品中文字幕一区二区小辣椒| 午夜欧美大尺度福利影院在线看| 中文字幕在线观看不卡| 国产精品天天摸av网| 中文字幕免费一区| 国产日产欧美一区二区视频| www激情久久| xvideos.蜜桃一区二区| 精品国产伦一区二区三区免费| 91精品国产手机| 91精品国产麻豆| 欧美电视剧在线观看完整版| 日韩视频永久免费| 91精品国产综合久久精品性色| 色8久久精品久久久久久蜜| 91丝袜美腿高跟国产极品老师 | 国内一区二区视频| 激情偷乱视频一区二区三区| 韩日精品视频一区| 国产成人午夜精品影院观看视频 | 91麻豆精品一区二区三区| www.亚洲精品| 91女神在线视频| 在线视频你懂得一区| 欧美日韩美少妇| 日韩欧美一区二区三区在线| 日韩欧美亚洲一区二区| 国产日韩欧美电影| 亚洲人成电影网站色mp4| 亚洲午夜国产一区99re久久| 日韩国产一区二| 国产精品综合久久| 91影视在线播放| 欧美日韩一区二区欧美激情| 日韩一级二级三级| 久久久久久99久久久精品网站| 中文字幕欧美三区| 亚洲福利视频导航| 国产乱码精品一区二区三| 91性感美女视频| 欧美一区二区三区精品| 2020国产成人综合网| 最新国产の精品合集bt伙计| 亚洲va天堂va国产va久| 国产精品一区专区| 色偷偷一区二区三区| 欧美嫩在线观看| 国产亚洲欧洲一区高清在线观看| 亚洲天堂av一区| 久88久久88久久久| 一本到不卡免费一区二区| 日韩免费视频一区| 一区二区三区在线播放| 老司机午夜精品| 99国产欧美另类久久久精品| 欧美日韩免费视频| 国产欧美一区二区精品性色| 亚洲电影在线播放| 成人午夜激情视频| 日韩三级视频在线看| 日韩毛片视频在线看| 蜜乳av一区二区| 在线亚洲免费视频| 亚洲国产精华液网站w| 美女视频一区二区| 欧美在线观看一二区| 国产亚洲欧美在线| 麻豆91精品视频| 欧美性猛交xxxx乱大交退制版| 亚洲国产一二三| 成人亚洲一区二区一| 日韩欧美国产一区二区三区| 一区二区三区中文字幕| 成人av在线资源| 亚洲精品一区二区三区香蕉| 日本亚洲欧美天堂免费| 欧美在线观看禁18| 亚洲三级久久久| 成人一级视频在线观看| 久久九九国产精品| 美女视频第一区二区三区免费观看网站| 色综合天天视频在线观看| 亚洲国产激情av| 岛国精品在线播放| 久久久久久久久久看片| 日本不卡高清视频| 欧美日韩美少妇| 亚洲一卡二卡三卡四卡无卡久久| 91视频你懂的| 最新中文字幕一区二区三区| 国产在线不卡一卡二卡三卡四卡| 欧美高清视频在线高清观看mv色露露十八| 日本一区二区三区在线不卡| 国产成人自拍高清视频在线免费播放| 日韩一区二区在线观看| 蜜臀a∨国产成人精品| 欧美一级精品在线| 美女国产一区二区| 精品成a人在线观看| 国产真实精品久久二三区| 久久久亚洲午夜电影| 国产不卡视频在线播放| 亚洲国产成人自拍|