Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Given a BST, find all sequences of nodes, that will generates the same bst.

$
0
0

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.


Viewing all articles
Browse latest Browse all 40121

Trending Articles