请帮助我获得在C ++中实现N元树的源代码 [英] Please help me to have the source code to implement N-ary Tree in C++

查看:93
本文介绍了请帮助我获得在C ++中实现N元树的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友
我在senario中可以有很多子节点到父节点,而且子节点可以有多个节点

我需要具有插入和搜索功能的代码.

请帮助

Dear Friends
I have senario where I can have many child node to the parent node and also the child node can have multiple number of node

I need to have the code to insert and search function.

Please help

推荐答案

请研究 B +树 [^ ].然后 N 可以是订单 [ Transwiki:B +树 [
Please research the B+ tree[^]. N can then be the order[^] of your B+ tree.

If you want to look into an existing implementation of a B+ tree in C++ have a look into this one here: Transwiki: B+ tree[^].

Regards,

Manfred


让我们启动解决方案.
Let''s kickstart you solution.
struct node
{
    struct node* parent;
    int number_of_sons;
    struct node* sons;
    int data_int;
    // char[64] data_str;
    // void* data_ptr;
}



现在,您必须实现:



Now, you have to implement:

int insert_tree(int data)
{
}





and

struct node* search_tree(int data)
{
}


我们不做您的作业:它的设置是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.

自己尝试,您可能会发现它并不像您想的那么困难!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!


这篇关于请帮助我获得在C ++中实现N元树的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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