c++ solution using dfs
\nclass Solution {\npublic:\n    vector<int>dp[100009];\n    vector<int>vis=vector<int>(100009,0);\n    void find(int x,vector<int>&nums)\n    {\n        if(vis
```\nclass Solution {\npublic:\n    vector<int>dp[100009];\n    vector<int>vis=vector<int>(100009,0);\n    void find(int x,vector<int>&nums)\n    {\n        if(vis[nums[x]])\n        {\n            return ;\n        }\n        vis[nums[x]]=1;\n        for(auto it:dp[x])\n        {\n            find(it,nums);\n        }\n    }\n    vector<int> smallestMissingValueSubtree(vector<int>& pt, vector<int>& nums) \n    {    \n        for(int i=1;i<pt.size();i++)\n        {\n            dp[pt[i]].push_back(i);\n        }\n        int index=-1;\n        for(int i=0;i<nums.size();i++)\n        {\n            if(nums[i]==1)\n            {\n                index=i;\n                break;\n            }\n        }\n        int element=1;\n        vector<int>ans(nums.size(),1);\n        while(index>-1)\n        {\n            find(index,nums);\n            while(vis[element])\n            {\n                element++;\n            }\n            ans[index]=element;\n            index=pt[index];\n        }\n        return ans;\n    }\n};\n```
['Depth-First Search', 'C', 'C++']