Print all nodes present in the subtree of a given node of a Binary Tree

#include
using namespace std;
  

void dfs(int x, vector& tree,
         map& child)
{
    
    tree.push_back(x);
  
    
    if (child.find(x) != child.end()) {
  
        
        
        for (int next : child[x]) {
            dfs(next, tree, child);
        }
    }
}
  

void SubtreeX(vector& nid,
              vector& pid, int x)
{
    int n = nid.size();
    map child;
  
    
    for (int i = 0; i < n; i++) {            if (child.find(pid[i])             == child.end()) {                             child[pid[i]] = vector();         }            child[pid[i]].push_back(nid[i]);     }             vector tree;             dfs(x, tree, child);        for (int node : tree) {         cout