Sir can you please explain the question and the sample input.I am unable to understand how to approach this question .
UNABLE TO UNDERSTAND THE QUESTION
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
Sir can you please send the recursive implementation for building a tree for the given sample input.I am unable to implement it.
2 test cases showing wrong out of 4.
#include using namespace std; class node { public: int data; node *left; node *right; node(int d) { data=d; left=NULL; right=NULL; } }; bool identical(node *root1,node *root2) { if(root1==NULL && root2==NULL) return 1; if(root1!=NULL && root2!=NULL) { return identical(root1->left,root2->left); return identical(root1->right,root2->right); } return 0; } node *build(string s) { if (s == “true”) { int d; cin >> d; node *root = new node(d); string l; cin >> l; if (l == “true”) { root->left = build(l); } string r; cin >> r; if (r == “true”) { root->right = build®; } return root; } return NULL; } int main() { node *root1=build(“true”); node *root2=build(“true”); bool temp=identical(root1,root2); if(temp) cout<<“true”; else cout<<“false”; }
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.