Permutations Of BST

Revision en2, by gXa, 2016-07-17 10:42:39

Hi everyone, I am trying to find all permutations of the input elements which will result in the same Binary Search tree as the one formed with the input array.

Eg: I/P: 4, 3, 1, 2, 6, 5, 7

o/p:4 , 6, 3, 7, 5, 1, 2

4, 3, 2, 1, 6, 5, 7

and so on.

I have gone through links on internet but could not code it.

I am unable to print all the permutations correctly. So, I request community to help me with logic ( if recurive function can be provided too )?

Thank You

Tags bst

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English gXa 2016-07-17 10:42:39 6 Tiny change: '5, 1, 2 \n4, 3, 2, 1' -
en1 English gXa 2016-07-17 10:41:48 510 Initial revision (published)