#include #include #include #include "BinarySearchTree.h" using namespace std; void printMenu(); void printTabs(int n); int main() { char choice = '0'; string filename; cout << " Binary Search Tree Balancing and Drawing " << endl; BinarySearchTree *root = NULL; ifstream infile; ofstream ofile; int k, count; while(choice != '5') { printMenu(); cout << endl << "Choice ? "; cin >> choice; switch(choice) { case '1' : cout << "Please enter name of data file " << endl; cin >> filename; infile.open(filename.c_str()); delete root; root = NULL; k=0; count=0; while(infile >> k) { root->insert(k,root,0); } infile.close(); root->setInOrderPos(root,count); break; case '2' : root->draw(root,true); root->serialiseInOrder(root); //cout << root->inOrder[0][0] << endl; break; case '3' : root->balance(root); break; case '4' : cout << "Please enter name of output file " << endl; cin >> filename; ofile.open(filename.c_str()); root->serialisePreOrder(root); for(int i = 0; i < root->getSize(root); i++) { ofile << root->nextPreOrder()[0] << endl; } ofile.close(); break; case '5' : return 0; } cout << endl <