I have a huge number of items to be stored in a collection. I need to locate an item by comparing it to a certain key and then tell if such an item exists. I use a binary search tree to do so.
class node
{
public:
node(const char *p_name) :
greater(NULL),
smaller(NULL),
name(p_name)
{}
node *find(const char *p_name)
{
node *l_retval = this;
for(; l_retval != NULL;)
{
int l = strcmp(p_name, l_retval->name.c_str());
if (l == 0) break; // found it
else
if (l > 0) l_retval = greater; // the node searched for is in the greater branch
else l_retval = smaller; // or in the smaller branch
}
return l_retval;
}
node *greater, *smaller;
std::string name; // or any other type of data you would like to store
};
如果随意添加这些物品,所有物品都将被罚款。 如果有时以定购方式添加物品,则我的《商业仲裁示范法》作为相关清单(见下文)。
问题在于:鉴于《巴塞尔协议书》(平衡或联系式清单),我如何平衡《巴塞尔协议书》,因此重新编排,不能有效地作为相关名单?
例子见C++,但问题适用于比C++全数多语文。
如果你向我提供能够帮助我的联系,感谢!