Given a Binary Search Tree, generate all the sequences which would create the same binary search tree.
For eg: if bst is
5
/ \
3 7
then output:
5 3 7
5 7 3
If bst is:
5
/ \
4 7
/ / \
1 6 10
then output:
5 4 1 7 6 10
5 4 7 1 6 10
5 4 7 6 1 10
5 4 7 6 10 1
5 7 4 1 6 10
and so on…
Any help to solve such question Recursively.