www.delorie.com/gnu/docs/avl/libavl_153.html   search  
 
Buy GNU books!


GNU libavl 2.0.1

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.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.

 
/* 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 @refalso{297

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]


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003