| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 835 人关注过本帖
标题:B-树的输出
只看楼主 加入收藏
闪闪4521
Rank: 1
等 级:新手上路
帖 子:196
专家分:0
注 册:2007-11-30
收藏
 问题点数:0 回复次数:4 
B-树的输出
我写了一个B-树的输入与删除的程序
但是在C++中输出的B-树太混乱了
有谁有比较好的想法或算法吗?
搜索更多相关主题的帖子: 输出 算法 删除 
2007-12-22 22:11
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
yes, show your work here.

I've implemented a B-Tree a few years ago --- don't know what you meaning by a neat display of a B-Tree.

I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-12-23 03:58
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
很复杂,从来没实现过,贴出来看看!

Fight  to win  or  die...
2007-12-23 10:44
闪闪4521
Rank: 1
等 级:新手上路
帖 子:196
专家分:0
注 册:2007-11-30
收藏
得分:0 
就是输出太混乱了,很不直观。
只是3阶的B-树,
我也不会图形,只是想要一个形象的显示B-树生成或是生成后的算法。
代码过会再发

[[italic] 本帖最后由 闪闪4521 于 2007-12-23 12:55 编辑 [/italic]]
2007-12-23 12:51
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
here is my code for display (code for the B-Tree specified in CLRS). Note that I used indentation to visualize parent-child relation. Aslo the depth or height is maintained in the display.

The intial call could be traverse(root, 0)

    void traverse(node* x, int depth) const
    {
        if(x != NULL)
        {
            int i;
            for(i=0; i<x->n; ++i)
                cout<< (char)(x->key)[i] <<" ";
            cout<<endl;
            if(x->leaf == false)
            {
                for(i=0; i<=x->n; ++i)
                {
                    for(int j=0; j<=depth; ++j)
                        cout<<"    ";
                    traverse(x->c[i], depth+1);
                }
            }
        }
    }

I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-12-28 12:43
快速回复:B-树的输出
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013908 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved