c++中的查找算法

本文中含有的是直接查找算法,折半查找法,二叉查找法

#include 
using namespace std;

#define Max 10;

typedef char Elm;
 
struct node
{
	Elm data;
	int key;
} ;
 //直接查找 
 int sequential_search(node *E,Elm e)
 {
 	bool flage=false;//标记有无找到 
	int l=0;
	while(le) binary_search(E,e,n,b);//递归调用查找 
 	else if(E[n].keydata = e;
		E->l = NULL;
		E->r = NULL;
		return;
	}
	else if (e > E->data) createtree(E->r, e);
	else if (e < E->data) createtree(E->l, e);
}
//查找 
 int  find(Node* E, Elm e)
{
	if (!E) return -1;
	if (e == E->data)
	{
		flage = true;
		return;
	}
	else if (e > E->data) find(E->r, e);
	else if (e < E->data) find(E->l, e);
}
 

猜你喜欢

转载自blog.csdn.net/play_841266670/article/details/73011809