```
int inorder[9999];
int size;
void traverse(struct TreeNode* node);
int kthSmallest(struct TreeNode* root, int k) {
size = 0;
traverse(root);
return inorder[k - 1];
}
void traverse(struct TreeNode* node){
if(node->left != NULL) traverse(node->left);
inorder[size++] = node->val;
if(node->right != NULL) traverse(node->right);
}
```