Not able to get the input format

How many nodes i need to insert or when to stop. Like there’s no -1 as input which denotes to stop taking further inputs. Also the way input format is printed can i take it in linear form as 1,2,2,2,3,0,4,0,5,2,6,0,7,0 as the nodes.

@Kishan-Mishra-2464674013761441 hey kishan
this is generic tree and for input go through this line of code
class node
{
public:
int data;
vector<node*> tree;
node(int n,int d)
{
tree.resize(n);
data=d;
}
};

node*buildtree()
{
int data,child;
cin>>data>>child;

node*root=new node(child,data);
for(int i=0;i<child;i++)
{
root->tree[i]=buildtree();
}

return root;

}

1 Like

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.