notes55

notes55 - AVL Tree Implementation Struct AVLNodecfw...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
February 27, 2006 AVL Tree Implementation Struct AVLNode{ int _height; char *_key; void *_data; AVLNode *_parent; AVLNode *_left, *_right; }; ------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------- ----- Class AVLTree{ AVLNode *_root; public: AVLTree( ); void insert( char *key, void *data ); void *find( char *key ); void remove( char *key ); void restructure( AVLNode *n ); }; ------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------- ----- AVLTree.cc #include "AVLTree.h" AVLTree::AVLTree( ){ _root = NULL; } Void AVLTree::insert( char *key, void *data ){ //Find node to insert into AVLNode *current = _root; AVLNode *previous = NULL;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
while( current != NULL ) { previous = current; if( strcmp( current->_key, key ) == 0 ) { //Found existing node, substitute data
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 7

notes55 - AVL Tree Implementation Struct AVLNodecfw...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online