In Dread Ink, the Grave Hand of Keith Thompson Did Inscribe:
All that's needed in this case is the phrase "Array based AVL Tree",
which the OP already knew well enough to put it in the subject header.
(A number of the top hits are now links to this thread.)
I've done a lot of googling for tree-related stuff in C, lately, and found
a lot of parts I needed, but never a closed-form source listing that was
going to survive being fed to a compiler.
The several links posted for this were an entirely different matter,
including a place where you can do a one-click download, which is nive for
the 400 lines that these programs get to be.
What makes these "array-based" avl trees? The "a" in avl is for Adelson.
Are there clues in these comments here:
0 * Small arrays to translate between balance (or diff) values and child
indeces.
101 *
102 * Code that deals with binary tree data structures will randomly
use
103 * left and right children when examining a tree. C "if()"
statements
104 * which evaluate randomly suffer from very poor hardware branch
prediction.
105 * In this code we avoid some of the branch mispredictions by using
the
106 * following translation arrays. They replace random branches with
an
107 * additional memory reference. Since the translation arrays are
both very
108 * small the data should remain efficiently in cache.
--
Frank
There's no liberal echo chamber in this country. There's a right-wing echo
chamber. I want to create a countervailing echo chamber.
~~ Al Franken, Chicago Tribune interview, on