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

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings