Share my C++ iterative ALG.
class Solution {\n    public:\n        int kthSmallest(TreeNode* root, int k) {\n            stack<TreeNode *> st;\n            TreeNode *p = root;\n           
    class Solution {\n    public:\n        int kthSmallest(TreeNode* root, int k) {\n            stack<TreeNode *> st;\n            TreeNode *p = root;\n            while(p || !st.empty())\n            {\n                while(p)\n                {\n                    st.push(p);\n                    p = p->left;\n                }\n                p = st.top();\n                if(--k == 0)\n                    return p->val;\n                st.pop();\n                p = p->right;\n            }\n        }\n    };
[]