January 2019
Intermediate to advanced
376 pages
8h 49m
English
The targeted properties you’ve seen so far are pretty representative of the whole thing. Aside from respecting their limitations (no recursive generators nor stats), not much changes. The path example from early in the chapter was easy for simulated annealing to handle, so in this section, we’ll explore a slightly trickier case: forcing trees to be more or less balanced or skewed, and how to best optimize that.
A binary tree[40] is generally simple to keep balanced when using random data; if the data’s randomness is uniform (or follows a standard distribution), chances are that you’ll get numbers that will naturally distribute themselves on both sides of the tree. But let’s validate that.
We’ll start by writing ...