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

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

?? binarytree.h

?? C++編成數(shù)據(jù)結構與程序設計方法 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一区二区三区免费野_久草精品视频
国产a久久麻豆| 精品少妇一区二区三区视频免付费 | 99久久国产综合色|国产精品| 看片的网站亚洲| 久久aⅴ国产欧美74aaa| 久久成人av少妇免费| 精品中文字幕一区二区| 久久99国产精品成人| 久久99精品久久久久久动态图| 美女视频一区在线观看| 麻豆一区二区三区| 国产麻豆9l精品三级站| 国产激情精品久久久第一区二区| 国产一区二区三区国产| 丁香亚洲综合激情啪啪综合| 风间由美中文字幕在线看视频国产欧美| 国产高清不卡二三区| 丁香天五香天堂综合| 99久久婷婷国产综合精品| 在线观看欧美日本| 91麻豆精品国产91久久久久久 | 成人动漫一区二区在线| 不卡区在线中文字幕| 色88888久久久久久影院野外| 色欧美88888久久久久久影院| 在线免费不卡电影| 日韩小视频在线观看专区| 久久综合久久综合久久| 国产精品欧美一区喷水| 一区二区欧美精品| 久久99精品网久久| 成人av综合一区| 欧美性大战久久久久久久蜜臀| 欧美精品一区二区三区很污很色的 | www.欧美.com| 欧美日韩国产片| 国产性天天综合网| 夜夜嗨av一区二区三区 | 欧美日韩成人综合天天影院 | 无码av免费一区二区三区试看| 麻豆一区二区三| 91香蕉视频黄| 欧美一级国产精品| 国产精品久久看| 男女男精品网站| 97久久超碰国产精品电影| 3d动漫精品啪啪一区二区竹菊 | 一区二区三区国产| 久久国产精品99久久人人澡| 成人av在线播放网址| 欧美精品乱码久久久久久按摩| 久久蜜臀中文字幕| 亚洲图片一区二区| 国产成人午夜电影网| 欧美色综合网站| 国产精品视频一二三| 琪琪久久久久日韩精品| 91视视频在线直接观看在线看网页在线看| 欧美日韩精品系列| 欧美激情综合在线| 人人精品人人爱| 99re热这里只有精品免费视频 | 奇米一区二区三区av| 97久久人人超碰| 精品国偷自产国产一区| 午夜影院久久久| 91丨九色丨尤物| 久久亚洲春色中文字幕久久久| 亚洲国产一区二区三区| 成人国产一区二区三区精品| 日韩一区二区三| 亚洲va在线va天堂| 色噜噜狠狠色综合欧洲selulu| 亚洲精品在线观看网站| 石原莉奈一区二区三区在线观看| 91麻豆.com| 国产农村妇女精品| 久久精品国产99国产精品| 久久久久久**毛片大全| 亚洲午夜久久久久中文字幕久| 成人污污视频在线观看| 精品国产亚洲在线| 蜜臀av性久久久久av蜜臀妖精| 欧美性三三影院| 亚洲精品免费电影| av一区二区三区四区| 国产日产欧美一区二区三区| 久久99日本精品| 欧美一区二区三区四区高清| 亚洲国产sm捆绑调教视频 | 国产精品久久久久影院色老大| 久久国产精品免费| 日韩欧美国产wwwww| 舔着乳尖日韩一区| 欧美视频在线不卡| 亚洲电影中文字幕在线观看| 91蝌蚪porny| 亚洲精品日韩一| 一本大道久久a久久精品综合| 亚洲欧美综合色| 色婷婷亚洲婷婷| 一区二区三区 在线观看视频| 色婷婷一区二区| 一区二区三区日韩欧美精品| 色天使久久综合网天天| 亚洲激情六月丁香| 精品视频999| 日本怡春院一区二区| 4438x亚洲最大成人网| 亚洲超碰精品一区二区| 欧美女孩性生活视频| 日韩精品一二三| 日韩一级片在线播放| 美女久久久精品| 久久久久久黄色| 97成人超碰视| 亚洲一区在线视频| 91精品国产色综合久久| 精品午夜久久福利影院| 久久综合色天天久久综合图片| 国产成人免费视| 亚洲日本一区二区三区| 欧美日韩情趣电影| 蜜桃视频在线一区| 国产性做久久久久久| 91在线观看高清| 亚洲国产裸拍裸体视频在线观看乱了| 91麻豆精品91久久久久同性| 美女视频网站久久| 欧美精彩视频一区二区三区| 成人丝袜高跟foot| 一二三区精品视频| 51午夜精品国产| 国产久卡久卡久卡久卡视频精品| 国产精品久久久久久一区二区三区| 色婷婷av一区二区三区大白胸| 天堂成人国产精品一区| 精品国产区一区| 成人精品在线视频观看| 亚洲国产一区视频| 26uuu国产日韩综合| 97精品国产97久久久久久久久久久久| 香蕉成人伊视频在线观看| 精品精品国产高清a毛片牛牛 | 久久精品夜夜夜夜久久| 日本道免费精品一区二区三区| 日韩激情av在线| 中文字幕 久热精品 视频在线| 欧美在线|欧美| 国产制服丝袜一区| 亚洲综合无码一区二区| 亚洲精品国产第一综合99久久 | 色拍拍在线精品视频8848| 免费成人av资源网| 国产午夜一区二区三区| 欧美三级在线看| 国产成人免费网站| 日本vs亚洲vs韩国一区三区二区| 国产精品女上位| 91精品国产高清一区二区三区 | 日韩欧美一级片| 91麻豆成人久久精品二区三区| 久久99精品久久久| 亚洲精品videosex极品| 久久综合狠狠综合久久综合88 | 欧美日韩在线三级| 国产sm精品调教视频网站| 亚洲午夜精品17c| 中文字幕一区二区三区不卡| 精品三级av在线| 欧美日韩精品系列| 91免费在线看| 成人免费视频一区二区| 另类欧美日韩国产在线| 亚洲影院在线观看| 中文字幕在线不卡一区 | 精品一区二区三区在线观看| 亚洲一卡二卡三卡四卡| 国产婷婷色一区二区三区 | 首页综合国产亚洲丝袜| 亚洲少妇中出一区| 国产日本一区二区| 久久久噜噜噜久久中文字幕色伊伊| 欧美天堂一区二区三区| 丁香桃色午夜亚洲一区二区三区| 久88久久88久久久| 首页国产欧美日韩丝袜| 玉米视频成人免费看| 国产精品国产三级国产aⅴ入口 | 精品不卡在线视频| 日韩视频中午一区| 欧美日精品一区视频| 91亚洲大成网污www| 成人一级片网址| 国产乱码精品一品二品| 国产一区欧美一区| 国产精品一区二区在线观看网站| 久久se精品一区精品二区| 日韩电影在线一区二区三区| 亚洲国产精品久久一线不卡|