Please Help Me!!!!!!!!

This is a discussion on Please Help Me!!!!!!!! within the C Programming forums, part of the General Programming Boards category; How do I write the tree traverse inorder to look like the actually tree when I output it. This is ...

  1. #1
    Unregistered
    Guest

    Unhappy Please Help Me!!!!!!!!

    How do I write the tree traverse inorder to look like the actually tree when I output it.

    This is what I got so far:
    void InOrderTraversal(struct Node *parent)
    {


    if(parent->Left!= NULL)
    InOrderTraversal(parent->Left);
    cout << endl;
    cout <<( parent->Data);
    if(parent->Right!=NULL)
    InOrderTraversal(parent->Right);

    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    function( Tree *t) {
      if(!t)return;
      if(t->left)function(t->left);
      if(t->right)function(t->right);
      display( t->data );
    }
    Yep. Basicly the same as yours, except I moved where I display the data.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21