Ten problems, each against a brute force on random trees (seeded) ================================================================= 1. validate BST: 20000 random binary trees, 7382 were BSTs; bounds and inorder agreed on all; childrenOnly wrongly accepted 417 2. kth smallest: 27427 (tree, k) cases against sorting all keys 3. lowest common ancestor: 18990 pairs against comparing the two root paths 4. range sum: 2000 cases against filtering all keys; sample tree [35, 50] = 125 5. sorted array to balanced BST: every n from 0 to 500 is a balanced BST of minimum height with the same keys 6. inorder successor: 2000 cases against scanning all keys; successor(40) in the sample tree = 50 7. two keys summing to a target: 2000 cases (359 true) against all pairs 8. minimum difference: 1729 trees against all pairs; MIN_VALUE and MAX_VALUE give 4294967295 (needs long) 9. recover two swapped keys: 1834 damaged trees, all restored 10. trim to a range: 2000 cases against filtering all keys, result still a BST; sample trimmed to [35, 65] = [35, 40, 50, 60, 65]