You are viewing a single comment's thread. Return to all comments →
Hope this helps, used a static count variable
void top_view(node * root) {
static int count=0; if (root->left && count>=0) { count++; top_view(root->left); } printf("%d ", root->data); count--; if (root->right && count<0) { count--; top_view(root->right); }
}
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 →
Hope this helps, used a static count variable
void top_view(node * root) {
}