// 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 <value> into a binary search tree rooted at <root>
// won't insert it again if it's already in the tree

bool bstFind(const bstPtr, const DataType);
// tries to find <value> in a binary search tree rooted at <root>

bool bstDelete(bstPtr &, const DataType);
// tries to delete <value> in a binary search tree rooted at <root>
// returns true if <value> 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
