|4.2.3 Maximum Height|
For efficiency, some of the BST routines use a stack of a fixed maximum height. This maximum height affects the maximum number of nodes that can be fully supported by libavl in any given tree, because a binary tree of height n contains at most 2**n - 1 nodes.
The BST_MAX_HEIGHT macro sets the maximum height of a BST. The default value of 64 allows for trees with up to 2**64 - 1. On today's common 32- and 64-bit computers, this is hardly a limit, because memory would be exhausted long before the tree became too big.
The BST routines that use fixed stacks also detect stack overflow and call a routine to “balance” or restructure the tree in order to reduce its height to the permissible range. The limit on the BST height is therefore not a severe restriction.
29. <BST maximum height 29> = /* Maximum BST height. */ #ifndef BST_MAX_HEIGHT #define BST_MAX_HEIGHT 32 #endif
This code is included in 25, 299, 417, and 521.
1. Suggest a reason why the BST_MAX_HEIGHT macro is defined conditionally. Are there any potential pitfalls? [answer]