C++(Recursive Approach and Morris Traversal)
Please Upvote if you like!\n\n# Recursive Approach:\n    int solve(TreeNode root,int &k)\n    {\n        if(root==NULL)\n            return 0;\n        int left
**Please Upvote if you like!**\n\n# Recursive Approach:\n    int solve(TreeNode *root,int &k)\n    {\n        if(root==NULL)\n            return 0;\n        int left=solve(root->left,k);\n        if(left!=NULL)\n            return left;\n        k=k-1;\n        if(k==0)\n        {\n            return root->val;\n        }\n        int right=solve(root->right,k);\n        return right;\n    }\n    int kthSmallest(TreeNode* root, int k)\n    {\n        return solve(root,k);\n    }\n\t\n# \t**Morris Traversal:**\n    class Solution {\n    public:\n    int solve(TreeNode *root,int &k)\n    {\n        if(root==NULL)\n            return 0;\n        int count=0;int res=0;\n        TreeNode *curr=root;\n        \n        while(curr)\n        {\n            if(curr->left==NULL)\n            {\n                count++;\n                if(count==k)\n                    res=curr->val;\n                curr=curr->right;\n            }\n            else\n            {\n                TreeNode*prev=curr->left;\n                while(prev->right && prev->right!=curr)\n                {\n                    prev=prev->right;\n                }\n                if(prev->right==NULL)\n                {\n                    prev->right=curr;\n                    curr=curr->left;\n                }\n                else\n                {\n                    prev->right=NULL;\n                    count++;\n                    if(count==k)\n                        res= curr->val;\n                    curr=curr->right;\n                }\n            }\n        }\n        return res;\n    }\n    int kthSmallest(TreeNode* root, int k)\n    {\n        return solve(root,k);\n    }\n    };
['Tree', 'Recursion', 'C']