Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.64.245
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/stutreeclient.cpp
/*      Author:         R.P. Patillo
        Instructor:     Dr. Ames
        Due Date:       Now. 13, 2008
        Complilation:   g++ stutreeclient.cpp -o stutreeclient.out
        Execution:      ./stutreeclient.out
*/

// stutreeclient.cpp - test client for gradetree class

#include "stutree.h"
#include <iostream>
using namespace std;

//---------------------------------------------------------------------------
int main()
{

   Gradetree grades;
   Gradetree othertree;	

   // First, add some unique grades

   grades.Insert (80);
   grades.Insert (75);
   grades.Insert (66);
   grades.Insert (78);
   grades.Insert (88);
   grades.Insert (86);
   grades.Insert (94);
   grades.Insert (92);
   grades.Insert (50);
   grades.Insert (68);
   grades.Insert (70);
   grades.Insert (98);
   grades.Insert (96);
   grades.Insert (97);

   // Display picture of tree

   cout << "\n\nAfter adding 80,75,66,78,88,86,94,92,50,68,70,98,96,97";
   cout << "\nSideways 'picture' of the tree:\n\n";
   grades.TreePicture ();

   // Next, add some duplicate grades

   grades.Insert (88);
   grades.Insert (50);
   grades.Insert (94);

   cout << "\n\nAfter adding duplicate 88, 50, 94";

   // Sum of grades
   cout << "\n\nThe sum of the grades in tree: " << grades.SumGrades();

   // Num of grades
   cout << "\n\nThe number of the grades in tree: " << grades.NumGrades();

   // Avg of grades
   cout << "\n\nThe average of the grades in tree: " << grades.AvgGrade();

   // Number of nodes
   cout << "\n\nThe number of nodes within tree: " << grades.NodeCount();

   // Number of leafs
   cout << "\n\nThe number of leaves in the tree: " << grades.LeafCount();

   // Number of non-leafs
   cout << "\n\nThe number of nodes that are not leaves within the tree: " << grades.NonLeafCount();

   // Height
   cout << "\n\nThe height of the tree: " << grades.Height();

   // Similar trees comparsion
   if(grades.SimilarTrees(othertree))
	cout << "\n\nThe trees are similar. ";
   else
	cout << "\n\nThe trees are not similar. ";

   // Make sure tree structure is still the same

   cout << "\nSideways 'picture' of the tree:\n\n";
   grades.TreePicture ();

   // Display the traversals

   cout << "\nTree Traversals:";
   cout << "\n PRE: ";
   grades.Preorder ();
   cout << "\nPOST: ";
   grades.Postorder ();
   cout << "\n  IN: ";
   grades.Inorder ();

   // Now delete key nodes and display picture after each

   grades.Delete (75);
   cout << "\n\nAfter deleting 75 (Case 3)\n\n";
   grades.TreePicture ();

   grades.Delete (98);
   cout << "\n\nAfter deleting 98 (Case 2)\n\n";
   grades.TreePicture ();

   grades.Delete (86);
   cout << "\n\nAfter deleting 86 (Case 1)\n\n";
   grades.TreePicture ();

   grades.Delete (97);
   cout << "\n\nAfter deleting 97 (Case 1)\n\n";
   grades.TreePicture ();

   cout << "\n\n";

   return 0;

}





Stv3n404 - 2023