0

need help-
create a tree(simple m-ary),with each node having 4 dataitems & 5 children. "IN C-language"

just 1 example showing 1 or 2 node created will be really helpfull(as this is tedious)........i have all operation clear till binary tree...but this 1 is not clicking!!!!.....

or in case u knw any link with ready-made Code...then the link.

Anything,any help is welcomed..
Thanks in advance.

Edited by simmi...: n/a

2
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by abhimanipal
0

Do you know how to create a binary tree ? It is the same principle, but instead of 2 children now you have 5 children.

Also does the problem state any restrictions on how you have to insert the node ? In the sense does the tree have to be balanced or you can insert the node where ever you want ?

0

So you can insert the node in which ever branch you chose to ?
PS: the level of help that you receive here often depends on how much detail you can provide

0

Node-1 with 5 chidren nodes node2 node3 node4 node5 node6...........

Node-1 contains 4 dataitems(integers)

the child node(node-2) to the left of dataitem-1 contains max. 4 values-all less than dataitem-1 of node-1
the child node(node-3) to the right of dataitem-1 contains max. 4 values-all greater than dataitem-1 of node-1 & less than dataitem-2 of node-1

the child node(node-4) to the right of dataitem-2 contains max. 4 values-all greater than dataitem-2 of node-1 & less than dataitem-3 of node-1 ................

Edited by simmi...: n/a

0

Following this criteria we are supposed to insert integer values in the tree....

No condition like each node must be at-least half full as this isn't like binary tree

0

The data structure of each node will be some thing of this sort

struct node
{
     int data[5];
     struct node* children[5];
     int count;
};

Create the head node first. The when you insert the next node, check how many children does head have. If it has less than 5 children, make the next node the child of the head. If not check how many children does the first child have then check for the 2nd child and so on
This approach is not complete but you can build on this now

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.