#include #include #include #include #include #include "bst.h" using namespace std; void lowerit(string & word){ int i; for(i = 0;i r) { return(l+1); } else { return(r+1); } } int height(BST T) { return(height2(T.root(),T)); } void inorderPrint(BST T) { position p; stackS; bool done = false;; if(T.size() > 0) { p = T.root(); while (!done) { if (NULL != T.leftChild(p)) { S.push(p); p = T.leftChild(p); } else if (NULL != T.rightChild(p)) { cout << T.element(p) << endl; p = T.rightChild(p); } else { cout << T.element(p) << endl; do { if(S.size() != 0) { p = S.top(); S.pop(); cout << T.element(p) << endl; } else { done = true; } } while ((T.rightChild(p) == NULL) && !done) ; if (p != NULL) { p = T.rightChild(p); } } } } return; } int main () { BST T; string word; ifstream infile; infile.open("charge.txt"); infile >> word; while(infile) { lowerit(word); chopit(word); if(word.size() > 0) { if (T.findElement(word) == NULL) { T.insertItem(word); } } infile >> word; } cout << endl << endl; cout <<"The words are " << endl; inorderPrint(T); cout << endl << endl; T.inorderPrint(cout); cout << "That is " << T.size() << " Different words " << endl; cout << "With a height of " << height(T) << endl; cout << endl << endl; cout << "Enter a word to delete " << endl; cin >> word; while(word != "QUIT") { T.removeElement(word); cout << endl<< endl; inorderPrint(T); cout << "Enter a word to delete " << endl; cin >> word; } }