|All-time Popular Problems|
|Maximum difference between node and its ancestor|
|Even and odd elements at even and odd positions|
|Immediate Smaller Element|
|Remove every k'th node|
|Maximum of all subarrays of size k|
|Boundary Traversal of binary tree|
Given root of binary search tree and K as input, find K-th smallest element in BST. Your task is to return the K-th smallest element in BST from the function k_smallest_element().
Note: The Time Complexity will be O(h) where h is the height of the Tree.
The first line of input will contain the number of test cases T. Then T test cases follow. First line of every test case will be n, denoting the number of nodes in the BST. Second line of every test case will be n spaced integers denoting the Integer value of Nodes in BST. Third line of every test case will be k, denoting kth the smallest number.
For each test case, output will be the kth smallest element of BST.
Example(To be used only for expected output):
20 8 4 22 12