algorithm - Binary Search Tree Shuffling and Resetting - Stack Overflow
One can construct a random binary trees out of a set of values by using the following algorithm:
Input: values
- randomly select a value as the root node - say r.
- r->left = recursively build a random binary tree out of values[0..r].
- r->right = recursively build a random binary tree out of values[r+1..values.length()-1].
- return r.
Read full article from algorithm - Binary Search Tree Shuffling and Resetting - Stack Overflow
No comments:
Post a Comment