8.1 Data Types |
The TAVL node structure takes the basic fields for a BST and adds a balance factor for AVL balancing and a pair of tag fields to allow for threading.
301. <TAVL node structure 301> = /* Characterizes a link as a child pointer or a thread. */ enum tavl_tag
{ TAVL_CHILD, /* Child pointer. */ TAVL_THREAD /* Thread. */ }; /* An TAVL tree node. */ struct tavl_node
{ struct tavl_node *tavl_link[2]; /* Subtrees. */ void *tavl_data; /* Pointer to data. */ unsigned char tavl_tag[2]; /* Tag fields. */ signed char tavl_balance; /* Balance factor. */ };
This code is included in 299.
Exercises:
1. struct avl_node contains three pointer members and a single character member, whereas struct tavl_node additionally contains an array of two characters. Is struct tavl_node necessarily larger than struct avl_node? [answer]