// Thu Feb 22 08:11:42 PST 2018 #include #include #include using namespace std; struct bstnode { float item; bstnode*left; bstnode*right; }; int numcomparison = 0; int maxint(int x,int y) { if (x < y) return y; else return x; } int bstcount(bstnode*root) { if (root == NULL) return 0; else return 1+bstcount(root->left)+bstcount(root->right); } int bstheight(bstnode*root) { if (root) return 1+maxint(bstheight(root->left),bstheight(root->right)); else return 0; } void insert(bstnode *& root, float x) { if (root == NULL) { root = new bstnode; root->item = x; root->left = NULL; root->right = NULL; } else { numcomparison++; if (x < root->item) insert(root->left,x); else insert(root->right,x); } } void inorder(bstnode*root) { if (root) { inorder(root->left); cout<item<right); } } void skipspace() { while (cin && isspace(cin.peek())) cin.ignore(); } int main() { cout << std::fixed; cout << std::setprecision(8); bstnode * tree = NULL; float x; while(cin.peek()!=EOF) { cin >> x; insert(tree,x); skipspace(); } inorder(tree); cout << "Tree has "<< bstcount(tree) <<" items"; cout << " and has height "<