We've expanded our news coverage and improved our search! Visit
oreilly.com for the latest or search for all things across O'Reilly!
Article:
 |
|
Scripting a Binary Tree Using Tcl
|
| Subject: |
|
binary trees... |
| Date: |
|
2005-01-31 13:38:16 |
| From: |
|
belman
|
|
|
|
The whole point of a binary tree is to enhance the performance of a linear search... the hash lookup provided by your "keyed lists" probably does more to hurt the performance of your algorithm than anything.
Make a three element array and use constants (or just simple variables that act as constants) and I imagine the performance of that algorithm will increase dramatically, as there isn't a second set of (unnecessary and potentially expensive) lookups performed while you descend the tree.
In the C example those names are nothing but sugar after the compiler is done with it - in your example, they are integral at every step in the execution.
|