Click to See Complete Forum and Search --> : mway tree in order traversal
SGSpecialK
April 15th, 2003, 11:33 PM
I've been working on this for a few days, and I can't seem to figure out how to print out the in order traversal of an m-way tree. Can anyone give me some idea on how to do this? I'm really frustrated with it.
I know for a binary tree it would look something like this:
void InOrderPrint(mwayNode *T)
{
if(T)
{
InOrderPrint (T->left);
InOrderPrint (T->right);
cout << T;
}
}
Would an m-way look anything like it?:confused:
Manish Malik
April 16th, 2003, 01:28 AM
If a node of a M-way Search Tree (inorder traversal is not defined for 'arbitary' M-way trees) has 'n' subtrees, then it would contain n-1 keys (2<n<M). To traverse as "inorder", do it in a similar fashion as you do in a binary tree,
Traverse subTree0
Visit key1
Traverse subTree1
Vist key2
Traverse subTree2
Visit key3
.
.
Visit key(n-1)
Traverse subTree(n-1)
SGSpecialK
April 16th, 2003, 11:46 PM
i know i've already asked this, but I've been up all night, and I still can't figure out how to print out an m-way tree with an in order traversal. Can anyone help? Someone did try to help me, but I got nowhere with it. HELP!
[Mod: Merged with existing thread. (Manish Malik)]
SGSpecialK
April 17th, 2003, 01:48 AM
can you by change give me any code on this?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.