traversal vector

Hi, I am unclear of how to access the data in a vector that stores a pointer to a struct. This is what I have.

1
2
3
4
5
6
7
 struct Node
    {
        int data;
        Node *left;
        Node *next;
    };
      vector<Node *> array;


1
2
3
4
5
6
7
8
9
void print()
{
  for(int i = 0; i < array.size(); i++)
  {
	if(array[i] != NULL){
	  cout << array[i]->data << " " << i << endl;
        }
   }
}


This work to print out only the first Node data but I need to get the data from left and next. I know it has to be recursion but have no idea how to do it.
The problem is that you selected incorrect approach. You should store nodes either as a linked list or as a vector.
Topic archived. No new replies allowed.