java – effectively find the kth the smallest element in the binary search tree?

The interview question below confronted me today and I found the solution below, but the interviewer was not happy. I'm not sure why ..

Given a binary search tree, find the k-th smallest element.

Is there a more effective or efficient way to solve this problem?

        / ************************************************ * ***
*
* Kth the smallest iterative
*
************************************************** *** /

public int kthSmallestIterative (root TreeNode, int k) {
Stack st = new stack <> ();

while (root! = null) {
st.push (root);
root = root.left;
}

while (k! = 0) {
TreeNode n = st.pop ();
k--;
if (k == 0)
returns n.data;
TreeNode right = n.right;
while (right! = null) {
st.push (right);
right = right.left;
}
}

return -1;
}

I mentioned the complexity of time and space as O (n). My iterative version takes extra space. Is there a way to do it without extra space?