You are viewing a single comment's thread. Return to all comments →
void topView(Node * root) { vector<int> vL, vR; Node *t = root; while(t){ t = t->left; if(t) vL.push_back(t->data); } t = root; while(t){ vR.push_back(t->data); t = t->right; } for(int i=vL.size()-1; i>=0; i--) cout<<vL[i]<<" "; for(int i=0; i<vR.size(); i++) cout<<vR[i]<<" "; } Can anyone explain why this code doesn't work?
Seems like cookies are disabled on this browser, please enable them to open this website
Tree : Top View
You are viewing a single comment's thread. Return to all comments →