Can you please provide the code how to take input
How to take Input
1 2
1 has 2 children now move to its childrens
2 2
2 has two children (als 2 is children of 1)
3 0
3 is one of the children of 2 and it has zero children means leaf node
4 0
4 is 2nd children of 2 and it has zero children means leaf node
5 2
5 is 2nd children of 1 and it has two children 6 and 7 see next two lines
6 0
7 0
2 (this is the level no)
use recursion to take input
hint:
Node* InputForGenricTree(){
//Enter Node Data
int d; cin>>d;
Node* nn=new Node(d);
// Enter no of children for node#
int c; cin>>c;
nn->child_count=c;
nn->children=new Node*[c];
for (int i=0;i<c;i++){
nn->children[i]=InputForGenricTree();
}
return nn;
}
if you have more doubts regarding this feel free to ask
and if your doubt is resolved please mark it as resolved from your doubt section in your course
little bit confusing can you please explain use -> opertor instead of & operator
-> is use to acess member of pointer (of object)
& this is for address of variabel
please write code in coding blocks ide and share link for same(takin input only)
giving correct output but passing testcase
passing or not passing testcases??
my code is just to take input
rest of code you have to write