Algorithm to find nth smallest element in Binary Tree(Not BST)
- Take dynamic Array(in c++/java)
- Traverse all the elements of The given Binary Tree using any traversal algorithm (inorder, preorder, postorder, levelorder method) and keep each element in dynamic array.
- Sort dynamic Array in non decreasing order.
- choose nth element in Array i.e Array[n].
Time complexity=O(n)+O(nlogn)+O(1)=O(nlogn).