CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Posts
    21

    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?

  2. #2
    Join Date
    Feb 2001
    Location
    teh INTARWEB
    Posts
    542
    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)

  3. #3
    Join Date
    Feb 2003
    Posts
    21

    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.

  4. #4
    Join Date
    Feb 2003
    Posts
    21
    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
  •  





Click Here to Expand Forum to Full Width

Featured