You are viewing a single comment's thread. Return to all comments →
I tried just the same but with vectors instead of lists. Why would I get a segmentation fault like i do?
void LevelOrder(node * root) { std::vector<node*> N; if( root ) { N.push_back( root ); for( std::vector<node*>::iterator i = N.begin(); i != N.end(); i++ ) { std::cout << (*i)->data << " "; if( (*i)->left ) N.push_back( (*i)->left ); if( (*i)->right ) N.push_back( (*i)->right ); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Level Order Traversal
You are viewing a single comment's thread. Return to all comments →
I tried just the same but with vectors instead of lists. Why would I get a segmentation fault like i do?