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


GNU libavl 2.0.1

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

5.9.3.3 Starting at the Last Node

The code to start from the greatest node in the tree is analogous to that for starting from the least node. The only difference is that we descend to the right instead:

 
void *
bst_t_last (struct bst_traverser *trav, struct bst_table *tree)
{ struct bst_node *x; assert (tree != NULL && trav != NULL); trav-&#62;bst_table = tree; trav-&#62;bst_height = 0; trav-&#62;bst_generation = tree-&#62;bst_generation; x = tree-&#62;bst_root; if (x != NULL) while (x-&#62;bst_link[1] != NULL)
{ if (trav-&#62;bst_height >= BST_MAX_HEIGHT)
{ bst_balance (tree); return bst_t_last (trav, tree); } trav-&#62;bst_stack[trav-&#62;bst_height++] = x; x = x-&#62;bst_link[1]; } trav-&#62;bst_node = x; return x != NULL ? x-&#62;bst_data : NULL; }
This code is included in @refalso{63


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