In some problem i was given nodes and edges then i constructed a tree via adjacency list then while treversing it inorder manner nothing is printing i think the problem is when there is no node present at leaf node.Please help

void inorder(int root,vector<int> treeR[],vector<int> node){

    if(!root){
        return;
    }
    inorder(treeR[root][0],treeR,node);
    cout<<node[root]<<" ";
    inorder(treeR[root][1],treeR,node);
    return;
}
  int main(){
    int t;
    cin>>t;
    for(int T=0;T<t;T++){
        int n;
        cin>>n;
        int val,u,v;
        vector<int> nodes;
        vector<int> treeR[n-1];

        for(int i=0;i<n;i++){
            cin>>val;
            nodes.push_back(val);
        }

        for(int i=0;i<n-1;i++){
                cin>>u>>v;
                treeR[u-1].push_back(v-1);
        }
        inorder(0,treeR,nodes);
    }    
}

0 Answers