Tree_Take_input
TreeNode <int>* takeInput(){
int rootData;
cout<<"Enter data: ";
cin>>rootData;
TreeNode <int>* root = new TreeNode<int>(rootData);
int n;
cout<<"Enter number of children of "<<rootData<<": ";
cin>>n;
for(int i=0;i<n;i++){
TreeNode<int>* child=takeInput();
root->children.push_back(child);
}
return root;
}
Comments
Post a Comment