// sl-4-DHBW-Inf2 #ifndef SUCHBAUM_H #define SUCHBAUM_H typedef int DataType; struct bsTree; typedef bsTree * bstPtr; // pointer to a struct bsTree { // binary search tree DataType value; bstPtr left,right; bsTree(DataType v, bstPtr l=NULL, bstPtr r=NULL): value(v), left(l), right(r) {} } ; // for easy initialization of dynamic variables generated with "new" void bstInsert(bstPtr &, const DataType); // inserts into a binary search tree rooted at // won't insert it again if it's already in the tree bool bstFind(const bstPtr, const DataType); // tries to find in a binary search tree rooted at bool bstDelete(bstPtr &, const DataType); // tries to delete in a binary search tree rooted at // returns true if was deleted, false if it isn't in the tree void preorder(const bstPtr); void inorder(const bstPtr); void postorder(const bstPtr); void delTree(const bstPtr root); bstPtr genBST(int[], int**, const int, const int, const int); // Werte, Wurzeln, Anzahl, linker/rechter Rand bstPtr optBST(int[], double[], const int); // Werte, Wahrscheinlichkeiten, Anzahl #endif