Skip to main content

Ordered Trees

generated description: tree.gif

The animation illustrates the effect of a series of assignments. It starts out by assigning (unsubscripted) A the value 4. Caché Basic reserves a memory location for A, and stores 4. By the way, all the locations in this example are set to 4; this is an arbitrary choice. Don't pay attention to the 4, pay attention to the tree built by these assignments.

The next three assignments store 4 in several array locations (5,9,7). Notice how these locations are shown as a new level or dimension in the tree, and that they are sorted based on the subscript value, regardless of the order of the statements. At this point, another language would need—at least—nine reserved memory locations, but so far A only uses four. The next two assignments use negative integer subscripts. This makes no sense in other languages, but they have a spot in the ordered tree that makes sense. Next, you see two assignments that use real number, fractional subscripts. Again, this only makes sense in an ordered tree.

The animation continues by assigning three array locations using non-numeric subscripts. All non-numeric locations sort to the right of numeric locations, but the non-numerics sort alphabetically. So far, the A array only has one dimension. The next three assignments create a second dimension, which is also sorted. The last assignment creates a third dimension.

FeedbackOpens in a new tab