Thread: Please Help Me!!!!!!!!

  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