C++ easy explaination Step By Step 100%
\n/*I ll be giving as much details as possible as to what s going on in the recursion stack.\nLets take the binary tree to be [10,5,15,3,7,null,18]\n\t\t\t\t\t\
```\n/*I ll be giving as much details as possible as to what s going on in the recursion stack.\nLets take the binary tree to be [10,5,15,3,7,null,18]\n\t\t\t\t\t\t\n\t\t\t\t\t\t10\n\t\t\t\t\t\t/\\\n\t\t\t\t\t  5  15\n\t\t\t\t\t /\\   \\\n\t\t\t       3  7   18\ndo your inorder traversal as routine\n                                                                      sum = 0\n                    |   3      |  \n                    |   5      |  \n                    |   10     |  <-------inorder(root->left)\n                    |__________|\n                    we reach the NULL condition of the traversal\n            as 3 has no left or right nodes a sum of 0 is passed to 3       3    <-\n                                                                           /  \\    \\\n                                                                         NULL  NULL 0\n           3 is popped out of the stack ans analyzed\n                    |          |  3\n                    |   5      |  \n                    |   10     |  <-------inorder(root->left)\n                    |__________|\n            but as 3 < 7 (L)\n            sum value is not changed                                   sum=0\n            then 7 is pushed into the stack\n                    |   7      |  \n                    |   5      |  \n                    |   10     |  <-------inorder(root->right)\n                    |__________|\n            as 7 has no leaf nodes inorder(root->left) = NULL\n                                   sum+=7(as 7 is in the range)       sum=7\n                                   inorder(root->right) = NULL\n                                   sum=7 is passed to the call stack\n                    |          |  7\n                    |   5      |  \n                    |   10     |  <-------inorder(root->left)\n                    |__________|\n                Now as both the left and right nodes are visited 5 is analyzed.\n                inorder(root->left) = 5\n                But since 5 is not in the range sum value doesnt change.\n                Now 5 is popped out of the stack.\n                    |          |   5   \n                    |          |  \n                    |   10     |  <-------inorder(root->left)\n                    |__________|\n                    inorder(rot->right)  continues excecution.\n                    |   18     |  \n                    |   15     |  \n                    |   10     |  <-------inorder(root->right)\n                    |__________|\n                    18 has no childeren thus sum=7 is passed on to the root.\n                    18 is not in the range so sum doesnt change.\n                    this process continues and 15 gets added to the sum giving sum=22\n                    then 10 gets added  sum=32\n                    */\n     int sum=0;\n    int inorder(TreeNode* root,int L,int R)\n    {\n        if(root){\n        inorder(root->left,L,R);\n        if(root->val>=L && root->val<=R)\n            sum+=root->val;\n        inorder(root->right,L,R);\n        }\n        return sum;\n    }\n    int rangeSumBST(TreeNode* root, int L, int R) {\n        if(!root)return 0;\n        return inorder(root,L,R);\n    }\n```
['C', 'C++']