0

I have a 2-3 tree with the following node structure:

struct node
{
    int value1, value2;
    node *parent, *left, *right, *middle;
}

The problem is I don't know how to parse the whole tree. I know how we search for it because you simply go to the right path. But how to I get to check all the nodes in the tree?

user3141607
  • 61
  • 1
  • 10

1 Answers1

1

Here is pseudocode, that might help:

   void ParseNode(node *n)
   {
        OperationToParseCurrentNode();

        if(n->left)
           ParseNode(n->left);
        if(n->middle)
           ParseNode(n->middle);
        if(n->right)
           ParseNode(n->right);
   }

This will traverse all nodes if you input the root node.

thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110