给予预订& inorder列表,如何构建相应的B-TREE? [英] Giving the preorder & inorder lists, How can be constructed the corresponding B-TREE ?

查看:63
本文介绍了给予预订& inorder列表,如何构建相应的B-TREE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如果我有预购和订购清单,我需要哪种算法

建立相应的B-TREE?我在哪里可以找到一些源代码?


谢谢

-

comp.lang.c.moderated - 审核地址: cl**@plethora.net

推荐答案

是否这个列表在其他名称中有_named_的可能性。如果没有,你可以解释什么是订单/预订单列表? (我知道你期待

回答,但我发帖提问!:)


谢谢,

Zaharije Pasalic
Is any chance that this list are _named_ in some another names. If not, can
you explain what is inorder/preorder list are? (I know that you expect
answer, but i post question !:)

Thanks,
Zaharije Pasalic


DavidMéndez写道:
David Méndez wrote:
如果我有预订和订单列表,我需要哪种算法来构建相应的B-TREE?我在哪里可以找到一些源代码?
If I have the preorder and inorder list, which algorithm does I need
to build the corresponding B-TREE? where can I find some source code?




做自己的功课。


-

Jason Whitehurst

-

comp.lang.c.moderated - 审核地址: cl * *@plethora.net


在文章< cl **************** @ plethora.net> ,

DavidMéndez< da ********** @ hotmail.com>写道:
In article <cl****************@plethora.net>,
David Méndez <da**********@hotmail.com> wrote:


如果我有预购和订单列表,我需要哪种算法来构建相应的B-TREE?哪里可以找到一些源代码?
Hi,

If I have the preorder and inorder list, which algorithm does I need to
build the corresponding B-TREE? where can I find some source code?




这里'tis:

--------

#include< stdio.h>

#include< stdlib.h>


typedef struct n {struct n * p1,* p2 ; int v;} n;


n * reconstruct_tree(n * p,n * i)

{

n * in2, * t1,* t2; int v; if(!i)返回i;

while(p-> p2)p = p-> p2; in2 = i;

do {

t1 = malloc(sizeof * t1); t2 = malloc(sizeof * t2);

if(!t1 ||!t2)返回0 ;

t1-> v = t2-> v = in2-> v; t2-> p1 = t2-> p2 = 0; t1-> p1 = in2; t1 - > p2 = t2;

if(t1-> p1-> p2)t1-> p1-> p2-> p1 = t1; if(t1-> p1 - > p1)t1-> p1-> p1-> p1-> p2 = t1;

in2 = t1-> p1-> p2;

} while(in2);

i = t1;

while(i-> p1-> p1){

in2 = i; v = in2-> v;

while(p-> v!= v&& p-> p1-> v!= v){

in2 = in2-> p1-> p1;

if(!in2){puts(" invalid input \\\
"); return 0;}

v = in2-> v;

} if(v == p-> v){

if(p-> p1){p = p- > p1; free(p-> p2); p-> p2 = 0;}

if(in2-> p1-> p1)in2-> p1-> p1-> p1-> p2 = in2-> p1-> p2;

if(in2-> p1-> p2)in2-> p1-> p2- > p1-> p1 = in2-> p1-> p1;

else(i = in2);

t1 = in2-> p2; t2 = in2-> p1-> p1; free(in2-> p1); free(in2);

t2-> p2-> p2 = t1;

} else {

t2 = p-> p1;

if(t2-> p1)t2-> p1-> p2 = t2- > p2; t2-> p2-> p1 = t1-> p1;

free(t2); in2 = in2-> p1-> p1;

if(in2-> p1-> p1)in2-> p1-> p1-> p1-> p2 = in2-> p1-> p2;

in2-> p1-> p1-> p1-> p1 = in2-> p1-> p1;

t1 = in2-> p2; t2 = in2-> ; p1-> p2; free(in2-> p1); free(in2);

t2-> p2-> p1 = t1;}}

free(p); t1 = i-> p2; free(i-> p1); free(i);

返回t1;

}

--------


请注意我故意介绍过唱歌le-character错误。

确保在交付之前找到并修复它。


如果它应该是C ++(我看到你已经在那里交叉了),会有更多错误,但是它们应该更容易修复。

dave

(识别root ,提取子树遍历,递归)


-

Dave Vandervies dj ****** @ csclub.uwaterloo.ca

曾经有一个名叫卡斯的巨人,他住在一个玻璃房子里。

他扔的每一块石头都表明他知道的很少。

(现在和玻璃押韵的是什么和卡斯? - 凯斯汤普森在CLC

-

comp.lang.c.moderated - 审核地址: cl ** @ plethora.net


这篇关于给予预订&amp; inorder列表,如何构建相应的B-TREE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆