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


GNU libavl 2.0.1

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

7.4.2 Step 2: Insert

 
n = pa[k - 1]-&#62;rb_link[da[k - 1]] =
  tree-&#62;rb_alloc-&#62;libavl_malloc (tree-&#62;rb_alloc, sizeof *n);
if (n == NULL)
  return NULL;
n-&#62;rb_data = item;
n-&#62;rb_link[0] = n-&#62;rb_link[1] = NULL;
n-&#62;rb_color = RB_RED;
tree-&#62;rb_count++;
tree-&#62;rb_generation++;
This code is included in @refalso{197

Exercises:

1. Why are new nodes colored red, instead of black? [answer]


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