/*----------------------------------------------------------------------------
*
*
* AVLTREE 1.0
* (c) Werner Van Belle aug 95
*
*
* NODE_ADT AddAvlNode(NODE_ADT root, NODE_ADT who)
* Voegt who toe aan root, geeft als resultaat de nieuwe root weer
* O(log2n)
*
* NODE_ADT SearchAvlNode(NODE_ADT root, SEARCH_DATA_ADT watte)
* Zoekt watte op in root, geeft als resultaat de bijhorende node weer
* O(<log2n)
*
* NODE_ADT DeleteAvlNode(NODE_ADT root, SEARCH_DATA_ADT wie)
* Verwijdert wie uit root, geeft als resultaat de nieuwe root weer
* O(log2n)
*
* int ValidAvlTree(NODE_ADT root)
* Controleert of de AVL-tree wel aan de AVL-voorwaarde voldoet. Hier
* wordt niet gecontroleerd of de linkerkinderen kleiner zijn dan root
* en de rechterkinderen groter zijn dan root
* O(n)
*
* int AvlTreeCount(NODE_ADT root)
* geeft weer hoeveel elementen in de tree steken.
* O(n)
*
* int AvlDepth(NODE_ADT root)
* geeft de maximum diepte van een pad doorheen de tree weer.
* O(n)
*
* void PrintAvlTree(NODE_ADT root, int diepte)
* Print de avltree. Deze functie is enkel aanwezig als PRINT_NODE
* gedefinieerd is. Het output formaat is
* .rechterkind
* rootzelf
* .linkerkind
*/
#ifndef NODE_ADT
#error Type NODE must be specified
#endif
/* voorbeeld:
* struct WoordKnoop {
* struct WoordKnoop *left;
* struct WoordKnoop *right;
* int flag;
* char *woord;};
* typedef struct WoordKnoop *TestNodeAdt;
* #define NODE_ADT TestNodeAdt
*/
#ifndef LEFT_NODE
#error Function LEFT_NODE must be specified
#endif
/* voorbeeld
* #define LEFT_NODE(watte) (watte->left)
*/
#ifndef RIGHT_NODE
#error Function RIGHT_NODE must be specified
#endif
/* voorbeeld
* #define RIGHT_NODE(watte) (watte->right)
*/
#ifndef SET_LEFT_NODE
#error Function SET_LEFT_NODE must be specified
#endif
/* voorbeeld
* #define SET_LEFT_NODE(watte,to) (watte->left=to)
*/
#ifndef SET_RIGHT_NODE
#error Function SET_RIGHT_NODE must be specified
#endif
/* voorbeeld
* #define SET_RIGHT_NODE(watte,to) (watte->right=to)
*/
#ifndef POSITIVE_FLAG
#error Function POSITIVE_FLAG must be specified
#endif
/* voorbeeld
* #define POSITIVE_FLAG(watte) (watte->flag==1)
*/
#ifndef NEGATIVE_FLAG
#error Funhction NEGATIVE_FLAG must be specified
#endif
/* voorbeeld
* #define NEGATIVE_FLAG(watte) (watte->flag==-1)
*/
#ifndef ZERO_FLAG
#error Function ZERO_FLAG must be specified
#endif
/* voorbeeld
* #define ZERO_FLAG(watte) (watte->flag==0)
*/
#ifndef SET_ZERO_FLAG
#error function SET_ZERO_FLAG must be specified
#endif
/* voorbeeld
* #define SET_ZERO_FLAG(watte) (watte->flag=0)
*/
#ifndef SET_POSITIVE_FLAG
#error function SET_POSITIVE_FLAG must be specified
#endif
/* voorbeeld
* #define SET_POSITIVE_FLAG(watte) (watte->flag=1)
*/
#ifndef SET_NEGATIVE_FLAG
#error function SET_NEGATIVE_FLAG must be specified
#endif
/* voorbeeld
* #define SET_NEGATIVE_FLAG(watte) (watte->flag=-1)
*/
#ifndef NULLNODE
#error Instance NULLNODE must exist
#endif
/* voorbeeld
* #define NULLNODE NULL
*/
#ifndef ISNULLNODE
#error Function ISNULLNODE must be specified
#endif
/* voorbeeld
* #define ISNULLNODE(wie) (!wie)
*/
#ifndef SEARCH_DATA_ADT
#error Type SEARCH_DATA_ADT must be specified
#endif
/* voorbeeld
* #define SEARCH_DATA_ADT char*
*/
#ifndef COMPARE_ADD_DATA
#error Function COMPARE_ADD_DATA must be specified
#endif
/* voorbeeld
* #define COMPARE_ADD_DATA(w1,w2) (strcmp(w1->woord,w2->woord))
*/
#ifndef COMPARE_SEARCH_DATA
#error Function COMPARE_SEARCH_DATA must be specified
#endif
/* voorbeeld
* #define COMPARE_SEARCH_DATA(inst,key) (strcmp(inst->woord,key))
*/
#ifndef DELETE_NODE
#error Function DELETE_NODE must be specified
#endif
/* voorbeeld
* #define DELETE_NODE(wie) (free(wie))
*/
NODE_ADT AddAvlNode(NODE_ADT root, NODE_ADT who);
NODE_ADT SearchAvlNode(NODE_ADT root, SEARCH_DATA_ADT watte);
NODE_ADT DeleteAvlNode(NODE_ADT root, SEARCH_DATA_ADT wie);
int ValidAvlTree(NODE_ADT root);
int AvlTreeCount(NODE_ADT root);
int AvlDepth(NODE_ADT root);
#ifdef PRINT_NODE
/* voorbeeld
* #define PRINT_NODE(wie) printf("[%c %s]",(wie->flag==1 ? '+' : (wie->flag==-1 ? '-' : '0')),wie->woord)
*/
void PrintAvlTree(NODE_ADT root, int diepte);
#endif