Generate Large Binary Tree
HardJane Street
0 views
0 likes
Tree Random PRNG
Problem Description
Generate Large Binary Tree
Create a function `generate()` that returns a binary tree. The tree should be finite but arbitrarily large, and the generation should be performed in constant time, O(1).
Example:
Input: generate()
Output: TreeNode with potentially very large, but finite number of nodesConstraints:
- The function must run in O(1) time.
- The tree generated must be finite but can be arbitrarily large.
Solution
Click to load code editor