No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
I am student of arid agriculture university,
the compiler compile the code,but traversing output is wrong .please chech ny logic is correct,tell me best tutorial to learn of binary tree using stack . void usman:: inorder() { stack<node*>s; node *t=root; while(!s.empty()||t!=NULL) { if(t!=NULL) { s.push(t); t=t->left; } else { t=s.top(); s.pop(); cout<<t->data<<","; t=t->right; } } } | |
Re:
How to write a C++ program doing the following : a series of names with no blank characters and displays the number of the names having more than ten charaters. the name must not exceed 25 characters and the series ends when the user enters the word "end". | |
#include<iostream> #include<stack> using namespace std; struct node #include<iostream> #include<stack> using namespace std; struct node { int data; node *left; node *right; }; class usman { private: node *root,*leaf; int count; public: usman(); //~usman(); bool input(); void call(); void preorder(); void postorder(); }; usman::usman() { root=leaf=NULL; count=0; } bool usman::input() { … | |
hy ,i make binary tree,the input of binary tree in correct.but issues traversing of binary tree using stack ,because the result of traversing is wrong .please solve this issues. #include<iostream> #include<stack> using namespace std; struct node { int data; node *left; node *right; }; class usman { private: node *root,*leaf; … |