您的位置:首页 > 其它

算法3.8查找二叉树

2017-03-13 20:59 148 查看
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<algorithm>
using namespace std;
struct nodetype{
int key;
nodetype* left;
nodetype* right;
};
typedef nodetype* node_pointer;

//算法3.8查找二叉树
void binsearchtree(node_pointer tree,int keyin,node_pointer &p)
{
bool found=false;
p=tree;
while(!found)
{
if(p->key==keyin)
{
found=true;
}
else of(keyin<p->key)
p=p->left;
else
p=p->right;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  二叉查找树