|
-
April 15th, 2003, 11:33 PM
#1
mway tree in order traversal
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?
-
April 16th, 2003, 01:28 AM
#2
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)
-
April 16th, 2003, 11:46 PM
#3
M-way
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)]
Last edited by Manish Malik; April 17th, 2003 at 12:17 AM.
-
April 17th, 2003, 01:48 AM
#4
can you by change give me any code on this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|