#include <iostream>
using namespace std;
class TreeNode {
public:
int data;
TreeNode *LeftChild;
TreeNode *RightChild;
TreeNode() :LeftChild(NULL), RightChild(NULL) {}
};
class BiSortTree {
private:
TreeNode *root;
int *info;
int size;
int loc;
TreeNode *CreateTree(TreeNode *p);
TreeNode* InsertNode(TreeNode *p, int d);
TreeNode* Search(TreeNode *p, int d);
void Delete(int d);
public:
BiSortTree(int s, int arr[]);
void CreateBiSortTree();
void InsertBiSortTree(int d);
void InOder(TreeNode *p);
void InOderTree();
void SearchData(int d);
void DeleteData(int d);
};
BiSortTree::BiSortTree(int s, int arr[]) {
loc = 1;
size = s;
info = new int[size];
for (int i = 0; i < size; i++)
info[i] = arr[i];
}
void BiSortTree::CreateBiSortTree() {
root = new TreeNode();
if (size)
root->data = info[0];
CreateTree(root);
}
TreeNode *BiSortTree::CreateTree(TreeNode *p) {
if (loc < size) {
if (p->data > info[loc])
C++二叉排序树之查找结点
最新推荐文章于 2020-12-10 06:59:32 发布
本文详细探讨了如何使用C++编程语言实现二叉排序树,并专注于查找节点的过程,同时关注计算查找节点的具体次数,以优化算法效率。
摘要由CSDN通过智能技术生成