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

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

?? binarytree.h

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

#include <iostream>
#include "myStack.h"

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.

    void nonRecursiveInTraversal() const;
    void nonRecursivePreTraversal() const;
    void nonRecursivePostTraversal() const;

    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;
}

//NonRecursive Traversal algorithms

template <class elemType>
void binaryTreeType<elemType>::nonRecursiveInTraversal() const
{
    stackType<nodeType<elemType>*> stack;
    nodeType<elemType> *current;
    current = root;

    while ((current != NULL) || (!stack.isEmptyStack()))
        if (current != NULL)
        {
            stack.push(current);
            current = current->lLink;
        }
        else
        {
            current = stack.top();
            stack.pop();
            cout << current->info << " ";
            current = current->rLink;
        }

    cout << endl;
} //end nonRecursiveInTraversal

template <class elemType>
void binaryTreeType<elemType>::nonRecursivePreTraversal() const
{
    stackType<nodeType<elemType>*> stack;
    nodeType<elemType> *current;

    current = root;

    while ((current != NULL) || (!stack.isEmptyStack()))
        if (current != NULL)
        {
            cout << current->info << " ";
            stack.push(current);
            current = current->lLink;
        }
        else
        {
            current = stack.top();
            stack.pop();
            current = current->rLink;
        }

    cout << endl;
} //end nonRecursivePreTraversal

template <class elemType>
void binaryTreeType<elemType>::nonRecursivePostTraversal() const
{
    cout << "See programming exercise 6." << endl;
} //end nonRecursivePostTraversal

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人激情小说网站| 亚洲mv大片欧洲mv大片精品| 亚洲色图一区二区三区| 亚洲大片在线观看| 精品一区二区在线视频| av在线播放成人| 3751色影院一区二区三区| 久久精品在线免费观看| 亚洲最大色网站| 麻豆成人在线观看| 色综合久久久久网| 日韩精品一区二区三区中文不卡| 国产精品久久久久久久久快鸭| 亚洲国产裸拍裸体视频在线观看乱了| 久久国产精品99久久久久久老狼| av在线不卡网| 欧美大胆一级视频| 亚洲男人天堂av网| 国产精品亚洲成人| 欧美日韩日本视频| 欧美国产日韩一二三区| 男人的天堂久久精品| 成人av在线一区二区三区| 欧美放荡的少妇| 亚洲欧洲制服丝袜| 国产在线播精品第三| 欧美性xxxxxxxx| 欧美韩日一区二区三区| 免费成人av资源网| 色94色欧美sute亚洲线路一久| 欧美精品一区二区三区蜜桃视频| 亚洲影视在线播放| gogogo免费视频观看亚洲一| 日韩美一区二区三区| 一区二区三区四区中文字幕| 国产精品12区| 精品免费视频一区二区| 午夜免费久久看| 色婷婷综合久久久中文一区二区 | 亚洲影院久久精品| 欧美日韩的一区二区| 国产精品乱子久久久久| 久久精品国产999大香线蕉| 在线观看亚洲精品| 国产精品久久久久永久免费观看 | 国产日韩欧美综合一区| 免费成人你懂的| 欧美日韩国产经典色站一区二区三区| 亚洲欧洲成人精品av97| 国产一区二区三区久久久| 日韩欧美在线综合网| 视频一区视频二区在线观看| 欧美一a一片一级一片| 亚洲欧美日韩在线| 成人动漫一区二区| 欧美国产日韩a欧美在线观看| 国产一区二区三区综合| 精品处破学生在线二十三| 男女男精品视频| 51午夜精品国产| 三级欧美韩日大片在线看| 欧美色倩网站大全免费| 亚洲韩国一区二区三区| 在线观看亚洲成人| 亚洲一区二区三区小说| 欧美日韩在线精品一区二区三区激情| 一区二区三区日韩欧美精品 | 亚洲第一狼人社区| 精品视频在线免费观看| 亚洲一二三四在线观看| 欧美性大战久久久| 婷婷激情综合网| 日韩一区二区在线免费观看| 另类中文字幕网| 欧美精品一区二区三区久久久| 激情深爱一区二区| 欧美国产日韩亚洲一区| 不卡视频在线观看| 一区二区三区四区不卡视频| 欧美三区在线视频| 日本一区中文字幕| 精品国产乱码久久久久久1区2区| 国产在线国偷精品产拍免费yy| 久久久久青草大香线综合精品| 国产成人夜色高潮福利影视| 国产精品美女久久久久aⅴ国产馆| 成人黄色综合网站| 亚洲精品乱码久久久久久久久| 国产精品久久久久一区| 99视频一区二区| 亚洲一区二区三区四区的| 在线不卡欧美精品一区二区三区| 久久9热精品视频| 久久久.com| 色偷偷久久一区二区三区| 婷婷成人综合网| 精品久久久影院| caoporm超碰国产精品| 夜夜嗨av一区二区三区四季av| 欧美理论电影在线| 国产一本一道久久香蕉| 亚洲日本乱码在线观看| 欧美日韩1区2区| 国产美女视频91| 亚洲三级免费观看| 欧美一级夜夜爽| 成人avav影音| 日日摸夜夜添夜夜添亚洲女人| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 国产不卡视频在线观看| 亚洲精品中文字幕在线观看| 欧美一区二区在线视频| 国产91在线看| 亚洲成人免费av| 欧美韩国日本不卡| 欧美肥大bbwbbw高潮| 成人免费高清视频| 天天色天天操综合| 国产精品毛片大码女人| 欧美日韩国产区一| 国产91在线看| 日韩精品午夜视频| 国产精品久久久一本精品| 日韩一区二区免费在线观看| 99精品视频在线观看免费| 免费观看一级欧美片| 亚洲精品亚洲人成人网在线播放| 欧美一级xxx| 91国内精品野花午夜精品| 激情综合色播激情啊| 亚洲综合视频在线| 中文字幕乱码一区二区免费| 欧美精三区欧美精三区| 91在线观看成人| 国产在线精品免费av| 亚洲精品v日韩精品| 国产片一区二区三区| 91精品国产麻豆| 91国产丝袜在线播放| 国产成人精品综合在线观看| 免费国产亚洲视频| 亚洲国产美女搞黄色| 另类调教123区 | 欧美视频一区二区三区在线观看 | 日本一区二区三区四区| 欧美一区二区精品久久911| 91尤物视频在线观看| 国产成a人亚洲| 久久99精品久久久久婷婷| 亚洲一区中文日韩| 综合电影一区二区三区 | www..com久久爱| 国产精品123| 狠狠色综合日日| 天天综合网天天综合色| 亚洲精品美国一| 亚洲欧美在线高清| 国产午夜亚洲精品午夜鲁丝片| 91精品中文字幕一区二区三区| 91黄视频在线观看| 不卡视频在线看| 成人av电影免费在线播放| 国产乱码精品一区二区三区av| 日本欧美大码aⅴ在线播放| 亚洲成年人网站在线观看| 一区二区在线电影| 亚洲欧美日韩国产一区二区三区| 国产欧美一区二区精品婷婷| 久久亚洲精华国产精华液 | 丁香天五香天堂综合| 国产精品一区二区在线看| 久久国产精品99久久久久久老狼| 日韩国产欧美在线观看| 日韩专区在线视频| 天天综合网 天天综合色| 亚洲国产一区二区三区青草影视| 亚洲综合丝袜美腿| 亚洲午夜久久久久| 亚洲午夜羞羞片| 亚洲电影一级片| 天天av天天翘天天综合网| 亚洲成人777| 美女视频一区二区三区| 老鸭窝一区二区久久精品| 精彩视频一区二区三区| 久久97超碰国产精品超碰| 国产专区综合网| 粉嫩绯色av一区二区在线观看| 成人激情综合网站| 91免费视频观看| 欧美三级视频在线| 91精品福利在线一区二区三区| 91精品国产麻豆| 久久综合999| 国产精品嫩草影院com| 亚洲精品少妇30p| 丝袜美腿高跟呻吟高潮一区| 美日韩一级片在线观看| 国产成人在线视频播放| 99精品视频免费在线观看|