Given an array that stores a complete Binary Search Tree, write a function that efficiently prints the given array in ascending order.
For example, given an array [4, 2, 5, 1, 3], the function should print 1, 2, 3, 4, 5
Inorder traversal of BST prints it in ascending order. The only trick is to modify recursion termination condition in standard Inorder Tree Traversal.
1 2 3 4 5
Time Complexity: O(n)
Please write comments if you find the above solution incorrect, or find better ways to solve the same problem.
- Find k-th smallest element in BST (Order Statistics in BST)
- Sorted Linked List to Balanced BST
- Sorted Array to Balanced BST
- Count inversions in an array | Set 2 (Using Self-Balancing BST)
- How to check if a given array represents a Binary Heap?
- Check if a given array can represent Preorder Traversal of Binary Search Tree
- Check if given sorted sub-sequence exists in binary search tree
- Check if an array represents Inorder of Binary Search tree or not
- Construct BST from its given level order traversal
- Minimum Possible value of |ai + aj - k| for given array and k.
- Flatten BST to sorted list | Decreasing order
- Check given array of size n can represent BST of n levels or not
- Closest greater or same value on left side for every element in array
- Remove minimum elements from array so that max <= 2 * min
- Find closest smaller value for every element in array